1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977
|
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
/**
* TEST: Test EU Debugger functionality
* Category: Core
* Mega feature: EUdebug
* Sub-category: EUdebug framework
* Functionality: eu debugger framework
* Test category: functionality test
*/
#include <grp.h>
#include <poll.h>
#include <pthread.h>
#include <pwd.h>
#include <sys/ioctl.h>
#include <sys/prctl.h>
#include "igt.h"
#include "igt_sysfs.h"
#include "intel_pat.h"
#include "lib/igt_syncobj.h"
#include "xe/xe_eudebug.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
/**
* SUBTEST: sysfs-toggle
* Functionality: enable
* Description:
* Exercise the debugger enable/disable sysfs toggle logic
*/
static void test_sysfs_toggle(int fd)
{
xe_eudebug_enable(fd, false);
igt_assert(!xe_eudebug_debugger_available(fd));
xe_eudebug_enable(fd, true);
igt_assert(xe_eudebug_debugger_available(fd));
xe_eudebug_enable(fd, true);
igt_assert(xe_eudebug_debugger_available(fd));
xe_eudebug_enable(fd, false);
igt_assert(!xe_eudebug_debugger_available(fd));
xe_eudebug_enable(fd, false);
igt_assert(!xe_eudebug_debugger_available(fd));
xe_eudebug_enable(fd, true);
igt_assert(xe_eudebug_debugger_available(fd));
}
#define STAGE_PRE_DEBUG_RESOURCES_DONE 1
#define STAGE_DISCOVERY_DONE 2
#define CREATE_VMS (1 << 0)
#define CREATE_EXEC_QUEUES (1 << 1)
#define VM_BIND (1 << 2)
#define VM_BIND_VM_DESTROY (1 << 3)
#define VM_BIND_EXTENDED (1 << 4)
#define VM_METADATA (1 << 5)
#define VM_BIND_METADATA (1 << 6)
#define VM_BIND_OP_MAP_USERPTR (1 << 7)
#define VM_BIND_DELAY_UFENCE_ACK (1 << 8)
#define VM_BIND_UFENCE_RECONNECT (1 << 9)
#define VM_BIND_UFENCE_SIGINT_CLIENT (1 << 10)
#define TEST_FAULTABLE (1 << 30)
#define TEST_DISCOVERY (1 << 31)
#define PAGE_SIZE SZ_4K
#define MDATA_SIZE (WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM * PAGE_SIZE)
#define BO_ADDR 0x1a0000
static struct drm_xe_vm_bind_op_ext_attach_debug *
basic_vm_bind_metadata_ext_prepare(int fd, struct xe_eudebug_client *c, uint8_t **data)
{
const uint32_t data_size = MDATA_SIZE;
struct drm_xe_vm_bind_op_ext_attach_debug *ext;
int i;
*data = calloc(data_size, sizeof(**data));
igt_assert(*data);
for (i = 0; i < data_size; i++)
(*data)[i] = (i + i / PAGE_SIZE) % 256;
ext = calloc(WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM, sizeof(*ext));
igt_assert(ext);
for (i = 0; i < WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM; i++) {
ext[i].base.name = XE_VM_BIND_OP_EXTENSIONS_ATTACH_DEBUG;
ext[i].metadata_id = xe_eudebug_client_metadata_create(c, fd, i,
(i + 1) * PAGE_SIZE, *data);
ext[i].cookie = i;
if (i < WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM - 1)
ext[i].base.next_extension = to_user_pointer(&ext[i + 1]);
}
return ext;
}
static void basic_vm_bind_metadata_ext_del(int fd, struct xe_eudebug_client *c,
struct drm_xe_vm_bind_op_ext_attach_debug *ext,
uint8_t *data)
{
for (int i = 0; i < WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM; i++)
xe_eudebug_client_metadata_destroy(c, fd, ext[i].metadata_id, i,
(i + 1) * PAGE_SIZE);
free(ext);
free(data);
}
static void basic_vm_bind_client(int fd, struct xe_eudebug_client *c)
{
struct drm_xe_vm_bind_op_ext_attach_debug *ext = NULL;
uint32_t vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
size_t bo_size = xe_get_default_alignment(fd);
bool test_discovery = c->flags & TEST_DISCOVERY;
bool test_metadata = c->flags & VM_BIND_METADATA;
uint32_t bo = xe_bo_create(fd, 0, bo_size,
system_memory(fd), 0);
uint64_t addr = 0x1a0000;
uint8_t *data = NULL;
if (test_metadata)
ext = basic_vm_bind_metadata_ext_prepare(fd, c, &data);
xe_eudebug_client_vm_bind_flags(c, fd, vm, bo, 0, addr,
bo_size, 0, NULL, 0, to_user_pointer(ext));
if (test_discovery) {
xe_eudebug_client_signal_stage(c, STAGE_PRE_DEBUG_RESOURCES_DONE);
xe_eudebug_client_wait_stage(c, STAGE_DISCOVERY_DONE);
}
xe_eudebug_client_vm_unbind(c, fd, vm, 0, addr, bo_size);
if (test_metadata)
basic_vm_bind_metadata_ext_del(fd, c, ext, data);
gem_close(fd, bo);
xe_eudebug_client_vm_destroy(c, fd, vm);
}
static void basic_vm_bind_vm_destroy_client(int fd, struct xe_eudebug_client *c)
{
uint32_t vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
size_t bo_size = xe_get_default_alignment(fd);
bool test_discovery = c->flags & TEST_DISCOVERY;
uint32_t bo = xe_bo_create(fd, 0, bo_size,
system_memory(fd), 0);
uint64_t addr = 0x1a0000;
if (test_discovery) {
vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, NULL, 0);
xe_vm_destroy(fd, vm);
xe_eudebug_client_signal_stage(c, STAGE_PRE_DEBUG_RESOURCES_DONE);
xe_eudebug_client_wait_stage(c, STAGE_DISCOVERY_DONE);
} else {
vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
xe_eudebug_client_vm_bind(c, fd, vm, bo, 0, addr, bo_size);
xe_eudebug_client_vm_destroy(c, fd, vm);
}
gem_close(fd, bo);
}
#define BO_ITEMS 4096
#define MIN_BO_SIZE (BO_ITEMS * sizeof(uint64_t))
union buf_id {
uint32_t fd;
void *userptr;
};
struct bind_list {
int fd;
uint32_t vm;
union buf_id *bo;
struct drm_xe_vm_bind_op *bind_ops;
unsigned int n;
};
static void *bo_get_ptr(int fd, struct drm_xe_vm_bind_op *o)
{
void *ptr;
if (o->op != DRM_XE_VM_BIND_OP_MAP_USERPTR)
ptr = xe_bo_map(fd, o->obj, o->range);
else
ptr = (void *)(uintptr_t)o->userptr;
igt_assert(ptr);
return ptr;
}
static void bo_put_ptr(int fd, struct drm_xe_vm_bind_op *o, void *ptr)
{
if (o->op != DRM_XE_VM_BIND_OP_MAP_USERPTR)
munmap(ptr, o->range);
}
static void bo_prime(int fd, struct drm_xe_vm_bind_op *o)
{
uint64_t *d;
uint64_t i;
d = bo_get_ptr(fd, o);
for (i = 0; i < o->range / sizeof(*d); i++)
d[i] = o->addr + i;
bo_put_ptr(fd, o, d);
}
static void bo_check(int fd, struct drm_xe_vm_bind_op *o)
{
uint64_t *d;
uint64_t i;
d = bo_get_ptr(fd, o);
for (i = 0; i < o->range / sizeof(*d); i++)
igt_assert_eq(d[i], o->addr + i + 1);
bo_put_ptr(fd, o, d);
}
static union buf_id *vm_create_objects(int fd, uint32_t bo_placement, uint32_t vm,
unsigned int size, unsigned int n)
{
union buf_id *bo;
unsigned int i;
bo = calloc(n, sizeof(*bo));
igt_assert(bo);
for (i = 0; i < n; i++) {
if (bo_placement) {
bo[i].fd = xe_bo_create(fd, vm, size, bo_placement,
DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
igt_assert(bo[i].fd);
} else {
bo[i].userptr = aligned_alloc(PAGE_SIZE, size);
igt_assert(bo[i].userptr);
}
}
return bo;
}
static struct bind_list *create_bind_list(int fd, uint32_t bo_placement,
uint32_t vm, unsigned int n,
unsigned int target_size)
{
unsigned int i = target_size ?: MIN_BO_SIZE;
const unsigned int bo_size = max_t(bo_size, xe_get_default_alignment(fd), i);
bool is_userptr = !bo_placement;
struct bind_list *bl;
bl = malloc(sizeof(*bl));
bl->fd = fd;
bl->vm = vm;
bl->bo = vm_create_objects(fd, bo_placement, vm, bo_size, n);
bl->n = n;
bl->bind_ops = calloc(n, sizeof(*bl->bind_ops));
igt_assert(bl->bind_ops);
for (i = 0; i < n; i++) {
struct drm_xe_vm_bind_op *o = &bl->bind_ops[i];
if (is_userptr) {
o->userptr = (uintptr_t)bl->bo[i].userptr;
o->op = DRM_XE_VM_BIND_OP_MAP_USERPTR;
} else {
o->obj = bl->bo[i].fd;
o->op = DRM_XE_VM_BIND_OP_MAP;
}
o->range = bo_size;
o->addr = BO_ADDR + 2 * i * bo_size;
o->pat_index = intel_get_pat_idx_wb(fd);
}
for (i = 0; i < bl->n; i++) {
struct drm_xe_vm_bind_op *o = &bl->bind_ops[i];
igt_debug("bo %d: addr 0x%llx, range 0x%llx\n", i, o->addr, o->range);
bo_prime(fd, o);
}
return bl;
}
static void do_bind_list(struct xe_eudebug_client *c,
struct bind_list *bl, bool sync)
{
struct drm_xe_sync uf_sync = {
.type = DRM_XE_SYNC_TYPE_USER_FENCE,
.flags = DRM_XE_SYNC_FLAG_SIGNAL,
.timeline_value = 1337,
};
uint64_t ref_seqno = 0, op_ref_seqno = 0;
uint64_t *fence_data;
int i;
if (sync) {
fence_data = aligned_alloc(xe_get_default_alignment(bl->fd),
sizeof(*fence_data));
igt_assert(fence_data);
uf_sync.addr = to_user_pointer(fence_data);
memset(fence_data, 0, sizeof(*fence_data));
}
xe_vm_bind_array(bl->fd, bl->vm, 0, bl->bind_ops, bl->n, &uf_sync, sync ? 1 : 0);
xe_eudebug_client_vm_bind_event(c, DRM_XE_EUDEBUG_EVENT_STATE_CHANGE,
bl->fd, bl->vm, 0, bl->n, &ref_seqno);
for (i = 0; i < bl->n; i++)
xe_eudebug_client_vm_bind_op_event(c, DRM_XE_EUDEBUG_EVENT_CREATE,
ref_seqno,
&op_ref_seqno,
bl->bind_ops[i].addr,
bl->bind_ops[i].range,
0);
if (sync) {
xe_wait_ufence(bl->fd, fence_data, uf_sync.timeline_value, 0,
XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * NSEC_PER_SEC);
free(fence_data);
}
}
static void free_bind_list(struct xe_eudebug_client *c, struct bind_list *bl)
{
unsigned int i;
for (i = 0; i < bl->n; i++) {
igt_debug("%d: checking 0x%llx (%lld)\n",
i, bl->bind_ops[i].addr, bl->bind_ops[i].addr);
bo_check(bl->fd, &bl->bind_ops[i]);
if (bl->bind_ops[i].op == DRM_XE_VM_BIND_OP_MAP_USERPTR)
free(bl->bo[i].userptr);
xe_eudebug_client_vm_unbind(c, bl->fd, bl->vm, 0,
bl->bind_ops[i].addr,
bl->bind_ops[i].range);
}
free(bl->bind_ops);
free(bl->bo);
free(bl);
}
static void vm_bind_client(int fd, struct xe_eudebug_client *c)
{
uint64_t op_ref_seqno, ref_seqno;
struct bind_list *bl;
bool test_discovery = c->flags & TEST_DISCOVERY;
size_t bo_size = 3 * xe_get_default_alignment(fd);
uint32_t bo[2] = {
xe_bo_create(fd, 0, bo_size, system_memory(fd), 0),
xe_bo_create(fd, 0, bo_size, system_memory(fd), 0),
};
uint32_t vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
uint64_t addr[] = {0x2a0000, 0x3a0000};
uint64_t rebind_bo_offset = 2 * bo_size / 3;
uint64_t size = bo_size / 3;
int i = 0;
if (test_discovery) {
xe_vm_bind_async(fd, vm, 0, bo[0], 0, addr[0], bo_size, NULL, 0);
xe_vm_unbind_async(fd, vm, 0, 0, addr[0] + size, size, NULL, 0);
xe_vm_bind_async(fd, vm, 0, bo[1], 0, addr[1], bo_size, NULL, 0);
xe_vm_bind_async(fd, vm, 0, bo[1], rebind_bo_offset, addr[1], size, NULL, 0);
bl = create_bind_list(fd, system_memory(fd), vm, 4, 0);
xe_vm_bind_array(bl->fd, bl->vm, 0, bl->bind_ops, bl->n, NULL, 0);
xe_vm_unbind_all_async(fd, vm, 0, bo[0], NULL, 0);
xe_eudebug_client_vm_bind_event(c, DRM_XE_EUDEBUG_EVENT_STATE_CHANGE,
bl->fd, bl->vm, 0, bl->n + 2, &ref_seqno);
xe_eudebug_client_vm_bind_op_event(c, DRM_XE_EUDEBUG_EVENT_CREATE, ref_seqno,
&op_ref_seqno, addr[1], size, 0);
xe_eudebug_client_vm_bind_op_event(c, DRM_XE_EUDEBUG_EVENT_CREATE, ref_seqno,
&op_ref_seqno, addr[1] + size, size * 2, 0);
for (i = 0; i < bl->n; i++)
xe_eudebug_client_vm_bind_op_event(c, DRM_XE_EUDEBUG_EVENT_CREATE,
ref_seqno, &op_ref_seqno,
bl->bind_ops[i].addr,
bl->bind_ops[i].range, 0);
xe_eudebug_client_signal_stage(c, STAGE_PRE_DEBUG_RESOURCES_DONE);
xe_eudebug_client_wait_stage(c, STAGE_DISCOVERY_DONE);
} else {
xe_eudebug_client_vm_bind(c, fd, vm, bo[0], 0, addr[0], bo_size);
xe_eudebug_client_vm_unbind(c, fd, vm, 0, addr[0] + size, size);
xe_eudebug_client_vm_bind(c, fd, vm, bo[1], 0, addr[1], bo_size);
xe_eudebug_client_vm_bind(c, fd, vm, bo[1], rebind_bo_offset, addr[1], size);
bl = create_bind_list(fd, system_memory(fd), vm, 4, 0);
do_bind_list(c, bl, false);
}
xe_vm_unbind_all_async(fd, vm, 0, bo[1], NULL, 0);
xe_eudebug_client_vm_bind_event(c, DRM_XE_EUDEBUG_EVENT_STATE_CHANGE, fd, vm, 0,
1, &ref_seqno);
xe_eudebug_client_vm_bind_op_event(c, DRM_XE_EUDEBUG_EVENT_DESTROY, ref_seqno,
&op_ref_seqno, 0, 0, 0);
gem_close(fd, bo[0]);
gem_close(fd, bo[1]);
xe_eudebug_client_vm_destroy(c, fd, vm);
}
static void run_basic_client(struct xe_eudebug_client *c)
{
int fd, i;
fd = xe_eudebug_client_open_driver(c);
if (c->flags & CREATE_VMS) {
const uint32_t flags[] = {
DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE | DRM_XE_VM_CREATE_FLAG_LR_MODE,
DRM_XE_VM_CREATE_FLAG_LR_MODE,
};
uint32_t vms[ARRAY_SIZE(flags)];
for (i = 0; i < ARRAY_SIZE(flags); i++)
vms[i] = xe_eudebug_client_vm_create(c, fd, flags[i], 0);
for (i--; i >= 0; i--)
xe_eudebug_client_vm_destroy(c, fd, vms[i]);
}
if (c->flags & CREATE_EXEC_QUEUES) {
struct drm_xe_exec_queue_create *create;
struct drm_xe_engine_class_instance *hwe;
struct drm_xe_ext_set_property eq_ext = {
.base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY,
.property = DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG,
.value = DRM_XE_EXEC_QUEUE_EUDEBUG_FLAG_ENABLE,
};
uint32_t vm;
create = calloc(xe_number_engines(fd), sizeof(*create));
vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
i = 0;
xe_eudebug_for_each_engine(fd, hwe) {
create[i].instances = to_user_pointer(hwe);
create[i].vm_id = vm;
create[i].width = 1;
create[i].num_placements = 1;
create[i].extensions = to_user_pointer(&eq_ext);
xe_eudebug_client_exec_queue_create(c, fd, &create[i++]);
}
while (--i >= 0)
xe_eudebug_client_exec_queue_destroy(c, fd, &create[i]);
xe_eudebug_client_vm_destroy(c, fd, vm);
}
if (c->flags & VM_BIND || c->flags & VM_BIND_METADATA)
basic_vm_bind_client(fd, c);
if (c->flags & VM_BIND_EXTENDED)
vm_bind_client(fd, c);
if (c->flags & VM_BIND_VM_DESTROY)
basic_vm_bind_vm_destroy_client(fd, c);
xe_eudebug_client_close_driver(c, fd);
}
static int read_event(int debugfd, struct drm_xe_eudebug_event *event)
{
int ret;
ret = igt_ioctl(debugfd, DRM_XE_EUDEBUG_IOCTL_READ_EVENT, event);
if (ret < 0)
return -errno;
return ret;
}
static int __read_event(int debugfd, struct drm_xe_eudebug_event *event)
{
int ret;
ret = ioctl(debugfd, DRM_XE_EUDEBUG_IOCTL_READ_EVENT, event);
if (ret < 0)
return -errno;
return ret;
}
static int poll_event(int fd, int timeout_ms)
{
int ret;
struct pollfd p = {
.fd = fd,
.events = POLLIN,
.revents = 0,
};
ret = poll(&p, 1, timeout_ms);
if (ret == -1)
return -errno;
return ret == 1 && (p.revents & POLLIN);
}
static int __debug_connect(int fd, int *debugfd, struct drm_xe_eudebug_connect *param)
{
int ret = 0;
*debugfd = igt_ioctl(fd, DRM_IOCTL_XE_EUDEBUG_CONNECT, param);
if (*debugfd < 0) {
ret = -errno;
igt_assume(ret != 0);
}
errno = 0;
return ret;
}
/**
* SUBTEST: basic-connect
* Functionality: attach
* Description:
* Exercise XE_EUDEBUG_CONNECT ioctl with passing
* valid and invalid params.
*/
static void test_connect(int fd)
{
struct drm_xe_eudebug_connect param = {};
int debugfd, ret;
pid_t *pid;
pid = mmap(NULL, sizeof(pid_t), PROT_WRITE,
MAP_SHARED | MAP_ANON, -1, 0);
/* get fresh unrelated pid */
igt_fork(child, 1)
*pid = getpid();
igt_waitchildren();
param.pid = *pid;
munmap(pid, sizeof(pid_t));
ret = __debug_connect(fd, &debugfd, ¶m);
igt_assert(debugfd == -1);
igt_assert_eq(ret, param.pid ? -ENOENT : -EINVAL);
param.pid = 0;
ret = __debug_connect(fd, &debugfd, ¶m);
igt_assert(debugfd == -1);
igt_assert_eq(ret, -EINVAL);
param.pid = getpid();
param.version = -1;
ret = __debug_connect(fd, &debugfd, ¶m);
igt_assert(debugfd == -1);
igt_assert_eq(ret, -EINVAL);
param.version = 0;
param.flags = ~0;
ret = __debug_connect(fd, &debugfd, ¶m);
igt_assert(debugfd == -1);
igt_assert_eq(ret, -EINVAL);
param.flags = 0;
param.extensions = ~0;
ret = __debug_connect(fd, &debugfd, ¶m);
igt_assert(debugfd == -1);
igt_assert_eq(ret, -EINVAL);
param.extensions = 0;
ret = __debug_connect(fd, &debugfd, ¶m);
igt_assert_neq(debugfd, -1);
igt_assert_eq(ret, 0);
close(debugfd);
}
static void switch_user(__uid_t uid, __gid_t gid)
{
struct group *gr;
__gid_t gr_v;
/* Users other then root need to belong to video group */
gr = getgrnam("video");
igt_assert(gr);
/* Drop all */
igt_assert_eq(setgroups(1, &gr->gr_gid), 0);
igt_assert_eq(setgid(gid), 0);
igt_assert_eq(setuid(uid), 0);
igt_assert_eq(getgroups(1, &gr_v), 1);
igt_assert_eq(gr_v, gr->gr_gid);
igt_assert_eq(getgid(), gid);
igt_assert_eq(getuid(), uid);
igt_assert_eq(prctl(PR_SET_DUMPABLE, 1L), 0);
}
/**
* SUBTEST: connect-user
* Functionality: attach
* Description:
* Verify unprivileged XE_EUDEBUG_CONNECT ioctl.
* Check:
* - user debugger to user workload connection
* - user debugger to other user workload connection
* - user debugger to privileged workload connection
*/
static void test_connect_user(int fd)
{
struct drm_xe_eudebug_connect param = {};
struct passwd *pwd, *pwd2;
const char *user1 = "lp";
const char *user2 = "mail";
int debugfd, ret, i;
int p1[2], p2[2];
__uid_t u1, u2;
__gid_t g1, g2;
int newfd;
pid_t pid;
#define NUM_USER_TESTS 4
#define P_APP 0
#define P_GDB 1
struct conn_user {
/* u[0] - process uid, u[1] - gdb uid */
__uid_t u[P_GDB + 1];
/* g[0] - process gid, g[1] - gdb gid */
__gid_t g[P_GDB + 1];
/* Expected fd from open */
int ret;
/* Skip this test case */
int skip;
const char *desc;
} test[NUM_USER_TESTS] = {};
igt_assert(!pipe(p1));
igt_assert(!pipe(p2));
pwd = getpwnam(user1);
igt_require(pwd);
u1 = pwd->pw_uid;
g1 = pwd->pw_gid;
/*
* Keep a copy of needed contents as it is a static
* memory area and subsequent calls will overwrite
* what's in.
* However getpwnam() returns NULL if cannot find
* user in passwd.
*/
setpwent();
pwd2 = getpwnam(user2);
if (pwd2) {
u2 = pwd2->pw_uid;
g2 = pwd2->pw_gid;
}
test[0].skip = !pwd;
test[0].u[P_GDB] = u1;
test[0].g[P_GDB] = g1;
test[0].ret = -EACCES;
test[0].desc = "User GDB to Root App";
test[1].skip = !pwd;
test[1].u[P_APP] = u1;
test[1].g[P_APP] = g1;
test[1].u[P_GDB] = u1;
test[1].g[P_GDB] = g1;
test[1].ret = 0;
test[1].desc = "User GDB to User App";
test[2].skip = !pwd;
test[2].u[P_APP] = u1;
test[2].g[P_APP] = g1;
test[2].ret = 0;
test[2].desc = "Root GDB to User App";
test[3].skip = !pwd2;
test[3].u[P_APP] = u1;
test[3].g[P_APP] = g1;
test[3].u[P_GDB] = u2;
test[3].g[P_GDB] = g2;
test[3].ret = -EACCES;
test[3].desc = "User GDB to Other User App";
if (!pwd2)
igt_warn("User %s not available in the system. Skipping subtests: %s.\n",
user2, test[3].desc);
for (i = 0; i < NUM_USER_TESTS; i++) {
if (test[i].skip) {
igt_debug("Subtest %s skipped\n", test[i].desc);
continue;
}
igt_debug("Executing connection: %s\n", test[i].desc);
igt_fork(child, 2) {
if (!child) {
if (test[i].u[P_APP])
switch_user(test[i].u[P_APP], test[i].g[P_APP]);
pid = getpid();
/* Signal the PID */
igt_assert(write(p1[1], &pid, sizeof(pid)) == sizeof(pid));
/* wait with exit */
igt_assert(read(p2[0], &pid, sizeof(pid)) == sizeof(pid));
} else {
if (test[i].u[P_GDB])
switch_user(test[i].u[P_GDB], test[i].g[P_GDB]);
igt_assert(read(p1[0], &pid, sizeof(pid)) == sizeof(pid));
param.pid = pid;
newfd = drm_open_driver(DRIVER_XE);
ret = __debug_connect(newfd, &debugfd, ¶m);
/* Release the app first */
igt_assert(write(p2[1], &pid, sizeof(pid)) == sizeof(pid));
igt_assert_eq(ret, test[i].ret);
if (!ret)
close(debugfd);
}
}
igt_waitchildren();
}
close(p1[0]);
close(p1[1]);
close(p2[0]);
close(p2[1]);
#undef NUM_USER_TESTS
#undef P_APP
#undef P_GDB
}
/**
* SUBTEST: basic-close
* Functionality: attach
* Description:
* Test whether eudebug can be reattached after closure.
*/
static void test_close(int fd)
{
struct drm_xe_eudebug_connect param = { 0, };
int debug_fd1, debug_fd2;
int fd2;
param.pid = getpid();
igt_assert_eq(__debug_connect(fd, &debug_fd1, ¶m), 0);
igt_assert(debug_fd1 >= 0);
igt_assert_eq(__debug_connect(fd, &debug_fd2, ¶m), -EBUSY);
igt_assert_eq(debug_fd2, -1);
close(debug_fd1);
fd2 = drm_open_driver(DRIVER_XE);
igt_assert_eq(__debug_connect(fd2, &debug_fd2, ¶m), 0);
igt_assert(debug_fd2 >= 0);
close(fd2);
close(debug_fd2);
close(debug_fd1);
}
/**
* SUBTEST: basic-read-event
* Functionality: events
* Description:
* Synchronously exercise eu debugger event polling and reading.
*/
#define MAX_EVENT_SIZE (32 * 1024)
static void test_read_event(int fd)
{
struct drm_xe_eudebug_event *event;
struct xe_eudebug_debugger *d;
struct xe_eudebug_client *c;
event = calloc(1, MAX_EVENT_SIZE);
igt_assert(event);
c = xe_eudebug_client_create(fd, run_basic_client, 0, NULL);
d = xe_eudebug_debugger_create(fd, 0, NULL);
igt_assert_eq(xe_eudebug_debugger_attach(d, c), 0);
igt_assert_eq(poll_event(d->fd, 500), 0);
/* Negative read event - no events to read */
event->len = MAX_EVENT_SIZE;
event->type = DRM_XE_EUDEBUG_EVENT_READ;
igt_assert_eq(read_event(d->fd, event), -ENOENT);
xe_eudebug_client_start(c);
/* Positive read event - client create */
igt_assert_eq(poll_event(d->fd, 500), 1);
event->type = DRM_XE_EUDEBUG_EVENT_READ;
igt_assert_eq(read_event(d->fd, event), 0);
igt_assert_eq(event->type, DRM_XE_EUDEBUG_EVENT_OPEN);
igt_assert_eq(event->flags, DRM_XE_EUDEBUG_EVENT_CREATE);
igt_assert_eq(poll_event(d->fd, 500), 1);
event->flags = 0;
/* Negative read event - bad event type */
event->len = MAX_EVENT_SIZE;
event->type = DRM_XE_EUDEBUG_EVENT_NONE;
igt_assert_eq(read_event(d->fd, event), -EINVAL);
event->type = DRM_XE_EUDEBUG_EVENT_READ;
/* Negative read event - bad event len */
event->len = 0;
igt_assert_eq(read_event(d->fd, event), -EINVAL);
igt_assert_eq(0, event->len);
/* Negative read event - bad event len */
event->len = sizeof(*event) - 1;
igt_assert_eq(read_event(d->fd, event), -EINVAL);
/* Negative read event - insufficient event len */
event->len = sizeof(*event);
igt_assert_eq(read_event(d->fd, event), -EMSGSIZE);
/* event->len should now contain exact len */
igt_assert_lt(sizeof(*event), event->len);
/* Negative read event - insufficient event len */
event->len = event->len - 1;
igt_assert_eq(read_event(d->fd, event), -EMSGSIZE);
/* event->len should now contain exact len */
igt_assert_lt(sizeof(*event), event->len);
/* Positive read event - client destroy */
igt_assert_eq(read_event(d->fd, event), 0);
igt_assert_eq(event->type, DRM_XE_EUDEBUG_EVENT_OPEN);
igt_assert_eq(event->flags, DRM_XE_EUDEBUG_EVENT_DESTROY);
fcntl(d->fd, F_SETFL, fcntl(d->fd, F_GETFL) | O_NONBLOCK);
igt_assert(fcntl(d->fd, F_GETFL) & O_NONBLOCK);
/* Negative read event - no events to read in non blocking mode */
igt_assert_eq(poll_event(d->fd, 500), 0);
event->len = MAX_EVENT_SIZE;
event->flags = 0;
event->type = DRM_XE_EUDEBUG_EVENT_READ;
igt_assert_eq(__read_event(d->fd, event), -EAGAIN);
xe_eudebug_client_wait_done(c);
xe_eudebug_client_stop(c);
/* Negative read event - no client process in non blocking mode */
igt_assert_eq(poll_event(d->fd, 500), 0);
igt_assert_eq(__read_event(d->fd, event), -EAGAIN);
xe_eudebug_debugger_destroy(d);
xe_eudebug_client_destroy(c);
free(event);
}
/**
* SUBTEST: basic-client
* Functionality: attach
* Description:
* Attach the debugger to process which opens and closes xe drm client.
*
* SUBTEST: basic-client-th
* Functionality: attach
* Description:
* Create client basic resources (vms) in multiple threads
*
* SUBTEST: multiple-sessions
* Functionality: multisessions
* Description:
* Simultaneously attach many debuggers to many processes.
* Each process opens and closes xe drm client and creates few resources.
*
* SUBTEST: basic-exec-queues
* Functionality: exec queues events
* Description:
* Attach the debugger to process which creates and destroys a few exec-queues.
*
* SUBTEST: basic-vms
* Functionality: VM events
* Description:
* Attach the debugger to process which creates and destroys a few vms.
*
* SUBTEST: basic-vm-bind
* Functionality: VM bind event
* Description:
* Attach the debugger to a process that performs synchronous vm bind
* and vm unbind.
*
* SUBTEST: basic-vm-bind-vm-destroy
* Functionality: VM bind event
* Description:
* Attach the debugger to a process that performs vm bind, and destroys
* the vm without unbinding. Make sure that we don't get unbind events.
*
* SUBTEST: basic-vm-bind-extended
* Functionality: VM bind event
* Description:
* Attach the debugger to a process that performs bind, bind array, rebind,
* partial unbind, unbind and unbind all operations.
*
* SUBTEST: multigpu-basic-client
* Functionality: attach multiGPU
* Description:
* Attach the debugger to process which opens and closes xe drm client on all Xe devices.
*
* SUBTEST: multigpu-basic-client-many
* Functionality: attach multiGPU
* Description:
* Simultaneously attach many debuggers to many processes on all Xe devices.
* Each process opens and closes xe drm client and creates few resources.
*/
static void test_basic_sessions(int fd, unsigned int flags, int count, bool match_opposite)
{
struct xe_eudebug_session **s;
int i;
s = calloc(count, sizeof(*s));
igt_assert(s);
for (i = 0; i < count; i++)
s[i] = xe_eudebug_session_create(fd, run_basic_client, flags, NULL);
for (i = 0; i < count; i++)
xe_eudebug_session_run(s[i]);
for (i = 0; i < count; i++)
xe_eudebug_session_check(s[i], match_opposite, 0);
for (i = 0; i < count; i++)
xe_eudebug_session_destroy(s[i]);
}
/**
* SUBTEST: basic-vm-bind-discovery
* Functionality: VM bind event
* Description:
* Attach the debugger to a process that performs vm-bind before attaching
* and check if the discovery process reports it.
*
* SUBTEST: basic-vm-bind-metadata-discovery
* Functionality: VM bind metadata
* Description:
* Attach the debugger to a process that performs vm-bind with metadata attached
* before attaching and check if the discovery process reports it.
*
* SUBTEST: basic-vm-bind-vm-destroy-discovery
* Functionality: VM bind event
* Description:
* Attach the debugger to a process that performs vm bind, and destroys
* the vm without unbinding before attaching. Make sure that we don't get
* any bind/unbind and vm create/destroy events.
*
* SUBTEST: basic-vm-bind-extended-discovery
* Functionality: VM bind event
* Description:
* Attach the debugger to a process that performs bind, bind array, rebind,
* partial unbind, and unbind all operations before attaching. Ensure that
* we get a only a singe 'VM_BIND' event from the discovery worker.
*/
static void test_basic_discovery(int fd, unsigned int flags, bool match_opposite)
{
struct xe_eudebug_debugger *d;
struct xe_eudebug_session *s;
struct xe_eudebug_client *c;
s = xe_eudebug_session_create(fd, run_basic_client, flags | TEST_DISCOVERY, NULL);
c = s->client;
d = s->debugger;
xe_eudebug_client_start(c);
xe_eudebug_debugger_wait_stage(s, STAGE_PRE_DEBUG_RESOURCES_DONE);
igt_assert_eq(xe_eudebug_debugger_attach(d, c), 0);
xe_eudebug_debugger_start_worker(d);
/* give the worker time to do it's job */
sleep(2);
xe_eudebug_debugger_signal_stage(d, STAGE_DISCOVERY_DONE);
xe_eudebug_client_wait_done(c);
xe_eudebug_debugger_stop_worker(d, 1);
xe_eudebug_event_log_print(d->log, true);
xe_eudebug_event_log_print(c->log, true);
xe_eudebug_session_check(s, match_opposite, 0);
xe_eudebug_session_destroy(s);
}
#define RESOURCE_COUNT 16
#define PRIMARY_THREAD (1 << 0)
#define DISCOVERY_CLOSE_CLIENT (1 << 1)
#define DISCOVERY_DESTROY_RESOURCES (1 << 2)
#define DISCOVERY_VM_BIND (1 << 3)
#define DISCOVERY_SIGINT (1 << 4)
static void run_discovery_client(struct xe_eudebug_client *c)
{
int fd[RESOURCE_COUNT], i;
bool skip_sleep = c->flags & (DISCOVERY_DESTROY_RESOURCES | DISCOVERY_CLOSE_CLIENT);
uint64_t addr = 0x1a0000;
srand(getpid());
for (i = 0; i < RESOURCE_COUNT; i++) {
struct drm_xe_engine_class_instance *hwe = NULL;
fd[i] = xe_eudebug_client_open_driver(c);
/* Get first */
xe_eudebug_for_each_engine(fd[i], hwe)
break;
igt_assert(hwe);
/*
* Give the debugger a break in event stream after every
* other client, that allows to read discovery and dettach in quiet.
*/
if (random() % 2 == 0 && !skip_sleep)
sleep(1);
for (int j = 0; j < RESOURCE_COUNT; j++) {
uint32_t vm = xe_eudebug_client_vm_create(c, fd[i],
DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
struct drm_xe_ext_set_property eq_ext = {
.base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY,
.property = DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG,
.value = DRM_XE_EXEC_QUEUE_EUDEBUG_FLAG_ENABLE,
};
struct drm_xe_exec_queue_create create = {
.width = 1,
.num_placements = 1,
.vm_id = vm,
.instances = to_user_pointer(hwe),
.extensions = to_user_pointer(&eq_ext),
};
const unsigned int bo_size = max_t(bo_size,
xe_get_default_alignment(fd[i]),
MIN_BO_SIZE);
uint32_t bo = xe_bo_create(fd[i], 0, bo_size, system_memory(fd[i]), 0);
xe_eudebug_client_exec_queue_create(c, fd[i], &create);
if (c->flags & DISCOVERY_VM_BIND) {
xe_eudebug_client_vm_bind(c, fd[i], vm, bo, 0, addr, bo_size);
addr += bo_size;
}
if (c->flags & DISCOVERY_DESTROY_RESOURCES) {
xe_eudebug_client_exec_queue_destroy(c, fd[i], &create);
xe_eudebug_client_vm_destroy(c, fd[i], create.vm_id);
gem_close(fd[i], bo);
}
}
if (c->flags & DISCOVERY_CLOSE_CLIENT)
xe_eudebug_client_close_driver(c, fd[i]);
}
}
/**
* SUBTEST: discovery-%s
* Functionality: event discovery
* Description: Race discovery against %arg[1] and the debugger dettach.
*
* arg[1]:
*
* @race: resources creation
* @race-sigint: resources creation with client interruption
* @race-vmbind: vm-bind operations
* @empty: resources destruction
* @empty-clients: client closure
*/
static void *discovery_race_thread(void *data)
{
struct {
uint64_t client_handle;
int vm_count;
int exec_queue_count;
int vm_bind_op_count;
} clients[RESOURCE_COUNT];
struct xe_eudebug_session *s = data;
int expected = RESOURCE_COUNT * (1 + 2 * RESOURCE_COUNT);
const int tries = 100;
bool done = false;
int ret = 0;
for (int try = 0; try < tries && !done; try++) {
ret = xe_eudebug_debugger_attach(s->debugger, s->client);
if (ret == -EBUSY) {
usleep(100000);
continue;
}
igt_assert_eq(ret, 0);
if (random() % 2) {
struct drm_xe_eudebug_event *e = NULL;
int max_worker_waits = 30;
int i = -1;
xe_eudebug_debugger_start_worker(s->debugger);
if (!s->client->done) {
/*
* Thread can starve for more than one second. Make
* sure we get at least one event before stopping.
*/
do
if (s->client->flags & DISCOVERY_SIGINT)
usleep(100000);
else
sleep(1);
while (!READ_ONCE(s->debugger->event_count) &&
--max_worker_waits);
igt_assert(READ_ONCE(s->debugger->event_count));
}
xe_eudebug_debugger_stop_worker(s->debugger, 1);
igt_debug("Resources discovered: %" PRIu64 "\n", s->debugger->event_count);
if (!s->client->done) {
xe_eudebug_for_each_event(e, s->debugger->log) {
if (e->type == DRM_XE_EUDEBUG_EVENT_OPEN) {
struct drm_xe_eudebug_event_client *eo = (void *)e;
if (i >= 0) {
igt_assert_eq(clients[i].vm_count,
RESOURCE_COUNT);
igt_assert_eq(clients[i].exec_queue_count,
RESOURCE_COUNT);
if (s->client->flags & DISCOVERY_VM_BIND)
igt_assert_eq(clients[i].vm_bind_op_count,
RESOURCE_COUNT);
}
igt_assert(++i < RESOURCE_COUNT);
clients[i].client_handle = eo->client_handle;
clients[i].vm_count = 0;
clients[i].exec_queue_count = 0;
clients[i].vm_bind_op_count = 0;
}
if (e->type == DRM_XE_EUDEBUG_EVENT_VM)
clients[i].vm_count++;
if (e->type == DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE)
clients[i].exec_queue_count++;
if (e->type == DRM_XE_EUDEBUG_EVENT_VM_BIND_OP)
clients[i].vm_bind_op_count++;
};
igt_assert_lte(0, i);
}
for (int j = 0; j < i; j++)
for (int k = 0; k < i; k++) {
if (k == j)
continue;
igt_assert_neq(clients[j].client_handle,
clients[k].client_handle);
}
if (s->debugger->event_count >= expected)
done = true;
}
xe_eudebug_debugger_detach(s->debugger);
s->debugger->log->head = 0;
s->debugger->event_count = 0;
}
/* Primary thread must read everything */
if (s->flags & PRIMARY_THREAD) {
while ((ret = xe_eudebug_debugger_attach(s->debugger, s->client)) == -EBUSY)
usleep(100000);
igt_assert_eq(ret, 0);
xe_eudebug_debugger_start_worker(s->debugger);
xe_eudebug_client_wait_done(s->client);
if (READ_ONCE(s->debugger->event_count) != expected)
sleep(5);
xe_eudebug_debugger_stop_worker(s->debugger, 1);
xe_eudebug_debugger_detach(s->debugger);
}
return NULL;
}
static void test_race_discovery(int fd, unsigned int flags, int clients)
{
const int debuggers_per_client = 3;
int count = clients * debuggers_per_client;
struct xe_eudebug_session *sessions, *s;
struct xe_eudebug_client *c;
pthread_t *threads;
int i, j;
sessions = calloc(count, sizeof(*sessions));
threads = calloc(count, sizeof(*threads));
for (i = 0; i < clients; i++) {
c = xe_eudebug_client_create(fd, run_discovery_client, flags, NULL);
for (j = 0; j < debuggers_per_client; j++) {
s = &sessions[i * debuggers_per_client + j];
s->client = c;
s->debugger = xe_eudebug_debugger_create(fd, flags, NULL);
s->flags = flags | (!j ? PRIMARY_THREAD : 0);
}
}
for (i = 0; i < count; i++) {
if (sessions[i].flags & PRIMARY_THREAD)
xe_eudebug_client_start(sessions[i].client);
pthread_create(&threads[i], NULL, discovery_race_thread, &sessions[i]);
}
if (flags & DISCOVERY_SIGINT) {
sleep(2);
sessions[0].client->done = 1;
kill(sessions[0].client->pid, SIGINT);
}
for (i = 0; i < count; i++) {
pthread_join(threads[i], NULL);
}
for (i = count - 1; i > 0; i--) {
if (sessions[i].flags & PRIMARY_THREAD) {
igt_assert_eq(sessions[i].client->seqno - 1,
sessions[i].debugger->event_count);
xe_eudebug_event_log_compare(sessions[0].debugger->log,
sessions[i].debugger->log,
XE_EUDEBUG_FILTER_EVENT_VM_BIND);
xe_eudebug_client_destroy(sessions[i].client);
}
xe_eudebug_debugger_destroy(sessions[i].debugger);
}
}
static void *attach_dettach_thread(void *data)
{
struct xe_eudebug_session *s = data;
const int tries = 100;
int ret = 0;
for (int try = 0; try < tries; try++) {
ret = xe_eudebug_debugger_attach(s->debugger, s->client);
if (ret == -EBUSY) {
usleep(100000);
continue;
}
igt_assert_eq(ret, 0);
if (random() % 2 == 0) {
xe_eudebug_debugger_start_worker(s->debugger);
xe_eudebug_debugger_stop_worker(s->debugger, 1);
}
xe_eudebug_debugger_detach(s->debugger);
s->debugger->log->head = 0;
s->debugger->event_count = 0;
}
return NULL;
}
static void test_empty_discovery(int fd, unsigned int flags, int clients)
{
struct xe_eudebug_session **s;
pthread_t *threads;
int i, expected = flags & DISCOVERY_CLOSE_CLIENT ? 0 : RESOURCE_COUNT;
igt_assert(flags & (DISCOVERY_DESTROY_RESOURCES | DISCOVERY_CLOSE_CLIENT));
s = calloc(clients, sizeof(struct xe_eudebug_session *));
threads = calloc(clients, sizeof(*threads));
for (i = 0; i < clients; i++)
s[i] = xe_eudebug_session_create(fd, run_discovery_client, flags, NULL);
for (i = 0; i < clients; i++) {
xe_eudebug_client_start(s[i]->client);
pthread_create(&threads[i], NULL, attach_dettach_thread, s[i]);
}
for (i = 0; i < clients; i++)
pthread_join(threads[i], NULL);
for (i = 0; i < clients; i++) {
xe_eudebug_client_wait_done(s[i]->client);
igt_assert_eq(xe_eudebug_debugger_attach(s[i]->debugger, s[i]->client), 0);
xe_eudebug_debugger_start_worker(s[i]->debugger);
xe_eudebug_debugger_stop_worker(s[i]->debugger, 5);
xe_eudebug_debugger_detach(s[i]->debugger);
igt_assert_eq(s[i]->debugger->event_count, expected);
xe_eudebug_session_destroy(s[i]);
}
}
static void ufence_ack_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_ufence *ef = (void *)e;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE)
xe_eudebug_ack_ufence(d->fd, ef);
}
typedef void (*client_run_t)(struct xe_eudebug_client *);
static void test_client_with_trigger(int fd, unsigned int flags, int count,
client_run_t client_fn, int type,
xe_eudebug_trigger_fn trigger_fn,
struct drm_xe_engine_class_instance *hwe,
bool match_opposite, uint32_t event_filter)
{
struct xe_eudebug_session **s;
int i;
s = calloc(count, sizeof(*s));
igt_assert(s);
for (i = 0; i < count; i++)
s[i] = xe_eudebug_session_create(fd, client_fn, flags, hwe);
if (trigger_fn)
for (i = 0; i < count; i++)
xe_eudebug_debugger_add_trigger(s[i]->debugger, type, trigger_fn);
for (i = 0; i < count; i++)
xe_eudebug_debugger_add_trigger(s[i]->debugger, DRM_XE_EUDEBUG_EVENT_VM_BIND_UFENCE,
ufence_ack_trigger);
for (i = 0; i < count; i++)
xe_eudebug_session_run(s[i]);
for (i = 0; i < count; i++)
xe_eudebug_session_check(s[i], match_opposite, event_filter);
for (i = 0; i < count; i++)
xe_eudebug_session_destroy(s[i]);
}
struct thread_fn_args {
struct xe_eudebug_client *client;
int fd;
};
static void *basic_client_th(void *data)
{
struct thread_fn_args *f = data;
struct xe_eudebug_client *c = f->client;
uint32_t *vms;
int fd, i, num_vms;
fd = f->fd;
igt_assert(fd);
num_vms = 2 + rand() % 16;
vms = calloc(num_vms, sizeof(*vms));
igt_assert(vms);
igt_debug("Create %d client vms\n", num_vms);
for (i = 0; i < num_vms; i++)
vms[i] = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
for (i = 0; i < num_vms; i++)
xe_eudebug_client_vm_destroy(c, fd, vms[i]);
free(vms);
return NULL;
}
static void run_basic_client_th(struct xe_eudebug_client *c)
{
struct thread_fn_args *args;
int i, num_threads, fd;
pthread_t *threads;
args = calloc(1, sizeof(*args));
igt_assert(args);
num_threads = 2 + random() % 16;
igt_debug("Run on %d threads\n", num_threads);
threads = calloc(num_threads, sizeof(*threads));
igt_assert(threads);
fd = xe_eudebug_client_open_driver(c);
args->client = c;
args->fd = fd;
for (i = 0; i < num_threads; i++)
pthread_create(&threads[i], NULL, basic_client_th, args);
for (i = 0; i < num_threads; i++)
pthread_join(threads[i], NULL);
xe_eudebug_client_close_driver(c, fd);
free(args);
free(threads);
}
static void test_basic_sessions_th(int fd, unsigned int flags, int num_clients, bool match_opposite)
{
test_client_with_trigger(fd, flags, num_clients, run_basic_client_th, 0, NULL, NULL,
match_opposite, 0);
}
static void vm_access_client(struct xe_eudebug_client *c)
{
struct drm_xe_engine_class_instance *hwe = c->ptr;
uint32_t vm_flags = DRM_XE_VM_CREATE_FLAG_LR_MODE;
uint32_t bo_placement;
struct bind_list *bl;
uint32_t vm;
int fd, i, j;
igt_debug("Using %s\n", xe_engine_class_string(hwe->engine_class));
fd = xe_eudebug_client_open_driver(c);
vm_flags |= (c->flags & TEST_FAULTABLE) ? DRM_XE_VM_CREATE_FLAG_FAULT_MODE : 0;
vm = xe_eudebug_client_vm_create(c, fd, vm_flags, 0);
if (c->flags & VM_BIND_OP_MAP_USERPTR)
bo_placement = 0;
else
bo_placement = vram_if_possible(fd, hwe->gt_id);
for (j = 0; j < 5; j++) {
unsigned int target_size = MIN_BO_SIZE * (1 << j);
bl = create_bind_list(fd, bo_placement, vm, 4, target_size);
do_bind_list(c, bl, true);
for (i = 0; i < bl->n; i++)
xe_eudebug_client_wait_stage(c, bl->bind_ops[i].addr);
free_bind_list(c, bl);
}
xe_eudebug_client_vm_destroy(c, fd, vm);
xe_eudebug_client_close_driver(c, fd);
}
static void debugger_test_vma(struct xe_eudebug_debugger *d,
uint64_t client_handle,
uint64_t vm_handle,
uint64_t va_start,
uint64_t va_length)
{
struct drm_xe_eudebug_vm_open vo = { 0, };
uint64_t *v1, *v2;
uint64_t items = va_length / sizeof(uint64_t);
uint64_t offset;
int fd;
int r, i;
v1 = malloc(va_length);
igt_assert(v1);
v2 = malloc(va_length);
igt_assert(v2);
vo.client_handle = client_handle;
vo.vm_handle = vm_handle;
fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
igt_assert_lte(0, fd);
r = pread(fd, v1, va_length, va_start);
igt_assert_eq(r, va_length);
for (i = 0; i < items; i++)
igt_assert_eq(v1[i], va_start + i);
/* random unaligned offset within the vm */
offset = 1 + random() % (va_length / 2);
r = pread(fd, (char *)v1 + offset, va_length - offset, va_start + offset);
igt_assert_eq(r, va_length - offset);
for (i = 0; i < items; i++)
igt_assert_eq(v1[i], va_start + i);
for (i = 0; i < items; i++)
v1[i] = va_start + i + 1;
r = pwrite(fd, v1, offset, va_start);
igt_assert_eq(r, offset);
r = pwrite(fd, (char *)v1 + offset, va_length - offset, va_start + offset);
igt_assert_eq(r, va_length - offset);
lseek(fd, va_start, SEEK_SET);
r = read(fd, v2, va_length);
igt_assert_eq(r, va_length);
for (i = 0; i < items; i++)
igt_assert_eq(v1[i], v2[i]);
fsync(fd);
close(fd);
free(v1);
free(v2);
}
static void vm_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_op *eo = (void *)e;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
struct drm_xe_eudebug_event_vm_bind *eb;
igt_debug("vm bind op event received with ref %lld, addr 0x%llx, range 0x%llx\n",
eo->vm_bind_ref_seqno,
eo->addr,
eo->range);
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, eo->vm_bind_ref_seqno);
igt_assert(eb);
debugger_test_vma(d, eb->client_handle, eb->vm_handle,
eo->addr, eo->range);
xe_eudebug_debugger_signal_stage(d, eo->addr);
}
}
/**
* SUBTEST: basic-vm-access
* Functionality: VM access
* Description:
* Exercise XE_EUDEBUG_VM_OPEN with pread and pwrite into the
* vm fd, concerning many different offsets inside the vm,
* and many virtual addresses of the vm_bound object.
*
* SUBTEST: basic-vm-access-faultable
* Functionality: VM access with FAULTABLE_VM
* Description:
* Fault variation of test basic-vm-access.
*
* SUBTEST: basic-vm-access-userptr
* Functionality: VM access
* Description:
* Exercise XE_EUDEBUG_VM_OPEN with pread and pwrite into the
* vm fd, concerning many different offsets inside the vm,
* and many virtual addresses of the vm_bound object, but backed
* by userptr.
*
* SUBTEST: basic-vm-access-userptr-faultable
* Functionality: VM access with FAULTABLE_VM
* Description:
* Fault variation of test basic-vm-access-userptr.
*/
static void test_vm_access(int fd, unsigned int flags, int num_clients)
{
struct drm_xe_engine_class_instance *hwe;
igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
xe_eudebug_for_each_engine(fd, hwe)
test_client_with_trigger(fd, flags, num_clients,
vm_access_client,
DRM_XE_EUDEBUG_EVENT_VM_BIND_OP,
vm_trigger, hwe,
false,
XE_EUDEBUG_FILTER_EVENT_VM_BIND_OP |
XE_EUDEBUG_FILTER_EVENT_VM_BIND_UFENCE);
}
static void debugger_test_vma_parameters(struct xe_eudebug_debugger *d,
uint64_t client_handle,
uint64_t vm_handle,
uint64_t va_start,
uint64_t va_length)
{
struct drm_xe_eudebug_vm_open vo = { 0, };
uint64_t *v;
uint64_t items = va_length / sizeof(uint64_t);
int fd;
int r, i;
v = malloc(va_length);
igt_assert(v);
/* Negative VM open - bad client handle */
vo.client_handle = client_handle + 123;
vo.vm_handle = vm_handle;
fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
igt_assert_lt(fd, 0);
/* Negative VM open - bad vm handle */
vo.client_handle = client_handle;
vo.vm_handle = vm_handle + 123;
fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
igt_assert_lt(fd, 0);
/* Positive VM open */
vo.client_handle = client_handle;
vo.vm_handle = vm_handle;
fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
igt_assert_lte(0, fd);
/* Negative pread - bad fd */
r = pread(fd + 123, v, va_length, va_start);
igt_assert_lt(r, 0);
/* Negative pread - bad va_start */
r = pread(fd, v, va_length, 0);
igt_assert_lt(r, 0);
/* Negative pread - bad va_start */
r = pread(fd, v, va_length, va_start - 1);
igt_assert_lt(r, 0);
/* Positive pread - zero va_length */
r = pread(fd, v, 0, va_start);
igt_assert_eq(r, 0);
/* Negative pread - out of range */
r = pread(fd, v, va_length + 1, va_start);
igt_assert_eq(r, va_length);
/* Negative pread - bad va_start */
r = pread(fd, v, 1, va_start + va_length);
igt_assert_lt(r, 0);
/* Positive pread - whole range */
r = pread(fd, v, va_length, va_start);
igt_assert_eq(r, va_length);
/* Positive pread */
r = pread(fd, v, 1, va_start + va_length - 1);
igt_assert_eq(r, 1);
for (i = 0; i < items; i++)
igt_assert_eq(v[i], va_start + i);
for (i = 0; i < items; i++)
v[i] = va_start + i + 1;
/* Negative pwrite - bad fd */
r = pwrite(fd + 123, v, va_length, va_start);
igt_assert_lt(r, 0);
/* Negative pwrite - bad va_start */
r = pwrite(fd, v, va_length, -1);
igt_assert_lt(r, 0);
/* Negative pwrite - zero va_start */
r = pwrite(fd, v, va_length, 0);
igt_assert_lt(r, 0);
/* Negative pwrite - bad va_length */
r = pwrite(fd, v, va_length + 1, va_start);
igt_assert_eq(r, va_length);
/* Positive pwrite - zero va_length */
r = pwrite(fd, v, 0, va_start);
igt_assert_eq(r, 0);
/* Positive pwrite */
r = pwrite(fd, v, va_length, va_start);
igt_assert_eq(r, va_length);
fsync(fd);
close(fd);
free(v);
}
static void vm_trigger_access_parameters(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_op *eo = (void *)e;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
struct drm_xe_eudebug_event_vm_bind *eb;
igt_debug("vm bind op event received with ref %lld, addr 0x%llx, range 0x%llx\n",
eo->vm_bind_ref_seqno,
eo->addr,
eo->range);
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, eo->vm_bind_ref_seqno);
igt_assert(eb);
debugger_test_vma_parameters(d, eb->client_handle, eb->vm_handle, eo->addr,
eo->range);
xe_eudebug_debugger_signal_stage(d, eo->addr);
}
}
/**
* SUBTEST: basic-vm-access-parameters
* Functionality: VM access
* Description:
* Check negative scenarios of VM_OPEN ioctl and pread/pwrite usage
* with bo backing storage.
*
* SUBTEST: basic-vm-access-parameters-faultable
* Functionality: VM access with FAULTABLE_VM
* Description:
* Fault variation of test basic-vm-access-parameters.
*
* SUBTEST: basic-vm-access-parameters-userptr
* Functionality: VM access
* Description:
* Check negative scenarios of VM_OPEN ioctl and pread/pwrite usage
* with userptr backing storage.
*
* SUBTEST: basic-vm-access-parameters-userptr-faultable
* Functionality: VM access with FAULTABLE_VM
* Description:
* Fault variation of test basic-vm-access-parameters-userptr.
*/
static void test_vm_access_parameters(int fd, unsigned int flags, int num_clients)
{
struct drm_xe_engine_class_instance *hwe;
igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
xe_eudebug_for_each_engine(fd, hwe)
test_client_with_trigger(fd, flags, num_clients,
vm_access_client,
DRM_XE_EUDEBUG_EVENT_VM_BIND_OP,
vm_trigger_access_parameters, hwe,
false,
XE_EUDEBUG_FILTER_EVENT_VM_BIND_OP |
XE_EUDEBUG_FILTER_EVENT_VM_BIND_UFENCE);
}
static void metadata_access_client(struct xe_eudebug_client *c)
{
const uint64_t addr = 0x1a0000;
struct drm_xe_vm_bind_op_ext_attach_debug *ext;
uint8_t *data;
size_t bo_size;
uint32_t bo, vm;
int fd, i;
fd = xe_eudebug_client_open_driver(c);
bo_size = xe_get_default_alignment(fd);
vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
bo = xe_bo_create(fd, vm, bo_size, system_memory(fd), 0);
ext = basic_vm_bind_metadata_ext_prepare(fd, c, &data);
xe_eudebug_client_vm_bind_flags(c, fd, vm, bo, 0, addr,
bo_size, 0, NULL, 0, to_user_pointer(ext));
for (i = 0; i < WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM; i++)
xe_eudebug_client_wait_stage(c, i);
xe_eudebug_client_vm_unbind(c, fd, vm, 0, addr, bo_size);
basic_vm_bind_metadata_ext_del(fd, c, ext, data);
close(bo);
xe_eudebug_client_vm_destroy(c, fd, vm);
xe_eudebug_client_close_driver(c, fd);
}
static void debugger_test_metadata(struct xe_eudebug_debugger *d,
uint64_t client_handle,
uint64_t metadata_handle,
uint64_t type,
uint64_t len)
{
struct drm_xe_eudebug_read_metadata rm = {
.client_handle = client_handle,
.metadata_handle = metadata_handle,
.size = len,
};
uint8_t *data;
int i;
data = malloc(len);
igt_assert(data);
rm.ptr = to_user_pointer(data);
igt_assert_eq(igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_READ_METADATA, &rm), 0);
/* syntetic check, test sets different size per metadata type */
igt_assert_eq((type + 1) * PAGE_SIZE, rm.size);
for (i = 0; i < rm.size; i++)
igt_assert_eq(data[i], (i + i / PAGE_SIZE) % 256);
free(data);
}
static void metadata_read_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_metadata *em = (void *)e;
/* syntetic check, test sets different size per metadata type */
igt_assert_eq((em->type + 1) * PAGE_SIZE, em->len);
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
debugger_test_metadata(d, em->client_handle, em->metadata_handle,
em->type, em->len);
xe_eudebug_debugger_signal_stage(d, em->type);
}
}
static void metadata_read_on_vm_bind_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_op_metadata *em = (void *)e;
struct drm_xe_eudebug_event_vm_bind_op *eo = (void *)e;
struct drm_xe_eudebug_event_vm_bind *eb;
/* For testing purpose client sets metadata_cookie = type */
/*
* Metadata event has a reference to vm-bind-op event which has a reference
* to vm-bind event which contains proper client-handle.
*/
eo = (struct drm_xe_eudebug_event_vm_bind_op *)
xe_eudebug_event_log_find_seqno(d->log, em->vm_bind_op_ref_seqno);
igt_assert(eo);
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, eo->vm_bind_ref_seqno);
igt_assert(eb);
debugger_test_metadata(d,
eb->client_handle,
em->metadata_handle,
em->metadata_cookie,
MDATA_SIZE); /* max size */
xe_eudebug_debugger_signal_stage(d, em->metadata_cookie);
}
/**
* SUBTEST: read-metadata
* Functionality: metadata
* Description:
* Exercise DRM_XE_EUDEBUG_IOCTL_READ_METADATA and debug metadata create|destroy events.
*/
static void test_metadata_read(int fd, unsigned int flags, int num_clients)
{
test_client_with_trigger(fd, flags, num_clients, metadata_access_client,
DRM_XE_EUDEBUG_EVENT_METADATA, metadata_read_trigger,
NULL, true, 0);
}
/**
* SUBTEST: attach-debug-metadata
* Functionality: metadata
* Description:
* Read debug metadata when vm_bind has it attached.
*/
static void test_metadata_attach(int fd, unsigned int flags, int num_clients)
{
test_client_with_trigger(fd, flags, num_clients, metadata_access_client,
DRM_XE_EUDEBUG_EVENT_VM_BIND_OP_METADATA,
metadata_read_on_vm_bind_trigger,
NULL, true, 0);
}
#define STAGE_CLIENT_WAIT_ON_UFENCE_DONE 1337
#define UFENCE_EVENT_COUNT_EXPECTED 4
#define UFENCE_EVENT_COUNT_MAX 100
struct ufence_bind {
struct drm_xe_sync f;
uint64_t addr;
uint64_t range;
uint64_t value;
struct {
uint64_t vm_sync;
} *fence_data;
};
static void client_wait_ufences(struct xe_eudebug_client *c,
int fd, struct ufence_bind *binds, int count)
{
const int64_t default_fence_timeout_ns = 500 * NSEC_PER_MSEC;
int64_t timeout_ns;
int err;
/* Ensure that wait on unacked ufence times out */
for (int i = 0; i < count; i++) {
struct ufence_bind *b = &binds[i];
timeout_ns = default_fence_timeout_ns;
err = __xe_wait_ufence(fd, &b->fence_data->vm_sync, b->f.timeline_value,
0, &timeout_ns);
igt_assert_eq(err, -ETIME);
igt_assert_neq(b->fence_data->vm_sync, b->f.timeline_value);
igt_debug("wait #%d blocked on ack\n", i);
}
/* Wait on fence timed out, now tell the debugger to ack */
xe_eudebug_client_signal_stage(c, STAGE_CLIENT_WAIT_ON_UFENCE_DONE);
/* Check that ack unblocks ufence */
for (int i = 0; i < count; i++) {
struct ufence_bind *b = &binds[i];
timeout_ns = XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * NSEC_PER_SEC;
err = __xe_wait_ufence(fd, &b->fence_data->vm_sync, b->f.timeline_value,
0, &timeout_ns);
igt_assert_eq(err, 0);
igt_assert_eq(b->fence_data->vm_sync, b->f.timeline_value);
igt_debug("wait #%d completed\n", i);
}
}
static struct ufence_bind *create_binds_with_ufence(int fd, int count)
{
struct ufence_bind *binds;
binds = calloc(count, sizeof(*binds));
igt_assert(binds);
for (int i = 0; i < count; i++) {
struct ufence_bind *b = &binds[i];
b->range = 0x1000;
b->addr = 0x100000 + b->range * i;
b->fence_data = aligned_alloc(xe_get_default_alignment(fd),
sizeof(*b->fence_data));
igt_assert(b->fence_data);
memset(b->fence_data, 0, sizeof(*b->fence_data));
b->f.type = DRM_XE_SYNC_TYPE_USER_FENCE;
b->f.flags = DRM_XE_SYNC_FLAG_SIGNAL;
b->f.addr = to_user_pointer(&b->fence_data->vm_sync);
b->f.timeline_value = UFENCE_EVENT_COUNT_EXPECTED + i;
}
return binds;
}
static void destroy_binds_with_ufence(struct ufence_bind *binds, int count)
{
for (int i = 0; i < count; i++)
free(binds[i].fence_data);
free(binds);
}
static void basic_ufence_client(struct xe_eudebug_client *c)
{
const unsigned int n = UFENCE_EVENT_COUNT_EXPECTED;
int fd = xe_eudebug_client_open_driver(c);
uint32_t vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
size_t bo_size = n * xe_get_default_alignment(fd);
uint32_t bo = xe_bo_create(fd, 0, bo_size,
system_memory(fd), 0);
struct ufence_bind *binds = create_binds_with_ufence(fd, n);
for (int i = 0; i < n; i++) {
struct ufence_bind *b = &binds[i];
xe_eudebug_client_vm_bind_flags(c, fd, vm, bo, 0, b->addr, b->range, 0,
&b->f, 1, 0);
}
client_wait_ufences(c, fd, binds, n);
for (int i = 0; i < n; i++) {
struct ufence_bind *b = &binds[i];
xe_eudebug_client_vm_unbind(c, fd, vm, 0, b->addr, b->range);
}
destroy_binds_with_ufence(binds, n);
gem_close(fd, bo);
xe_eudebug_client_vm_destroy(c, fd, vm);
xe_eudebug_client_close_driver(c, fd);
}
struct ufence_priv {
struct drm_xe_eudebug_event_vm_bind_ufence ufence_events[UFENCE_EVENT_COUNT_MAX];
uint64_t ufence_event_seqno[UFENCE_EVENT_COUNT_MAX];
uint64_t ufence_event_vm_addr_start[UFENCE_EVENT_COUNT_MAX];
uint64_t ufence_event_vm_addr_range[UFENCE_EVENT_COUNT_MAX];
unsigned int ufence_event_count;
unsigned int vm_bind_op_count;
pthread_mutex_t mutex;
};
static struct ufence_priv *ufence_priv_create(void)
{
pthread_mutexattr_t attr;
struct ufence_priv *priv;
priv = mmap(0, ALIGN(sizeof(*priv), PAGE_SIZE),
PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
igt_assert(priv);
memset(priv, 0, sizeof(*priv));
pthread_mutexattr_init(&attr);
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(&priv->mutex, &attr);
pthread_mutexattr_destroy(&attr);
return priv;
}
static void ufence_priv_destroy(struct ufence_priv *priv)
{
pthread_mutex_destroy(&priv->mutex);
munmap(priv, ALIGN(sizeof(*priv), PAGE_SIZE));
}
static void ack_fences(struct xe_eudebug_debugger *d)
{
struct ufence_priv *priv = d->ptr;
for (int i = 0; i < priv->ufence_event_count; i++)
xe_eudebug_ack_ufence(d->fd, &priv->ufence_events[i]);
}
static void basic_ufence_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_ufence *ef = (void *)e;
struct ufence_priv *priv = d->ptr;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
char event_str[XE_EUDEBUG_EVENT_STRING_MAX_LEN];
struct drm_xe_eudebug_event_vm_bind *eb;
xe_eudebug_event_to_str(e, event_str, XE_EUDEBUG_EVENT_STRING_MAX_LEN);
igt_debug("ufence event received: %s\n", event_str);
xe_eudebug_assert_f(d, priv->ufence_event_count < UFENCE_EVENT_COUNT_EXPECTED,
"surplus ufence event received: %s\n", event_str);
xe_eudebug_assert(d, ef->vm_bind_ref_seqno);
memcpy(&priv->ufence_events[priv->ufence_event_count++], ef, sizeof(*ef));
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, ef->vm_bind_ref_seqno);
xe_eudebug_assert_f(d, eb, "vm bind event with seqno (%lld) not found\n",
ef->vm_bind_ref_seqno);
xe_eudebug_assert_f(d, eb->flags & DRM_XE_EUDEBUG_EVENT_VM_BIND_FLAG_UFENCE,
"vm bind event does not have ufence: %s\n", event_str);
}
}
static int wait_for_ufence_events(struct ufence_priv *priv, int timeout_ms)
{
int ret = -ETIMEDOUT;
igt_for_milliseconds(timeout_ms) {
pthread_mutex_lock(&priv->mutex);
if (priv->ufence_event_count == UFENCE_EVENT_COUNT_EXPECTED)
ret = 0;
pthread_mutex_unlock(&priv->mutex);
if (!ret)
break;
usleep(1000);
}
return ret;
}
/**
* SUBTEST: basic-vm-bind-ufence
* Functionality: VM bind event
* Description:
* Give user fence in application and check if ufence ack works
*
* SUBTEST: basic-vm-bind-ufence-delay-ack
* Functionality: VM bind event
* Description:
* Give user fence in application and check if delayed ufence ack works
*
* SUBTEST: basic-vm-bind-ufence-reconnect
* Functionality: VM bind event
* Description:
* Give user fence in application, hold it, drop the debugger connection and check if anything
* breaks. Expect that held acks are released when connection is dropped.
*
* SUBTEST: basic-vm-bind-ufence-sigint-client
* Functionality: SIGINT
* Description:
* Give user fence in application, hold it, send SIGINT to client and check if anything breaks.
*/
static void test_basic_ufence(int fd, unsigned int flags)
{
struct xe_eudebug_debugger *d;
struct xe_eudebug_session *s;
struct xe_eudebug_client *c;
struct ufence_priv *priv;
uint32_t filter = XE_EUDEBUG_FILTER_EVENT_VM_BIND_UFENCE;
priv = ufence_priv_create();
s = xe_eudebug_session_create(fd, basic_ufence_client, flags, priv);
c = s->client;
d = s->debugger;
xe_eudebug_debugger_add_trigger(d,
DRM_XE_EUDEBUG_EVENT_VM_BIND_UFENCE,
basic_ufence_trigger);
igt_assert_eq(xe_eudebug_debugger_attach(d, c), 0);
xe_eudebug_debugger_start_worker(d);
xe_eudebug_client_start(c);
xe_eudebug_debugger_wait_stage(s, STAGE_CLIENT_WAIT_ON_UFENCE_DONE);
xe_eudebug_assert_f(d, wait_for_ufence_events(priv, XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * MSEC_PER_SEC) == 0,
"missing ufence events\n");
if (flags & VM_BIND_DELAY_UFENCE_ACK)
sleep(XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * 4 / 5);
if (flags & VM_BIND_UFENCE_SIGINT_CLIENT) {
filter = XE_EUDEBUG_FILTER_ALL;
kill(c->pid, SIGINT);
c->pid = 0;
c->done = 1;
} else if (flags & VM_BIND_UFENCE_RECONNECT) {
filter = XE_EUDEBUG_FILTER_EVENT_VM_BIND | XE_EUDEBUG_FILTER_EVENT_VM |
XE_EUDEBUG_FILTER_EVENT_OPEN;
xe_eudebug_debugger_detach(d);
xe_eudebug_client_wait_done(c);
igt_assert_eq(xe_eudebug_debugger_attach(d, c), 0);
} else {
ack_fences(d);
}
xe_eudebug_client_wait_done(c);
xe_eudebug_debugger_stop_worker(d, 1);
xe_eudebug_event_log_print(d->log, true);
xe_eudebug_event_log_print(c->log, true);
xe_eudebug_session_check(s, true, filter);
xe_eudebug_session_destroy(s);
ufence_priv_destroy(priv);
}
struct vm_bind_clear_thread_priv {
struct drm_xe_engine_class_instance *hwe;
struct xe_eudebug_client *c;
pthread_t thread;
uint64_t region;
unsigned long sum;
};
struct vm_bind_clear_priv {
unsigned long unbind_count;
unsigned long bind_count;
unsigned long sum;
};
static struct vm_bind_clear_priv *vm_bind_clear_priv_create(void)
{
struct vm_bind_clear_priv *priv;
priv = mmap(0, ALIGN(sizeof(*priv), PAGE_SIZE),
PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
igt_assert(priv);
memset(priv, 0, sizeof(*priv));
return priv;
}
static void vm_bind_clear_priv_destroy(struct vm_bind_clear_priv *priv)
{
munmap(priv, ALIGN(sizeof(*priv), PAGE_SIZE));
}
static void *vm_bind_clear_thread(void *data)
{
const uint32_t CS_GPR0 = 0x600;
const size_t batch_size = 16;
struct drm_xe_sync uf_sync = {
.type = DRM_XE_SYNC_TYPE_USER_FENCE, .flags = DRM_XE_SYNC_FLAG_SIGNAL,
};
struct vm_bind_clear_thread_priv *priv = data;
int fd = xe_eudebug_client_open_driver(priv->c);
uint32_t gtt_size = 1ull << min_t(uint32_t, xe_va_bits(fd), 48);
uint32_t vm_flags = DRM_XE_VM_CREATE_FLAG_LR_MODE;
size_t bo_size = xe_bb_size(fd, batch_size);
unsigned long count = 0;
uint64_t *fence_data;
uint32_t vm;
vm_flags |= (priv->c->flags & TEST_FAULTABLE) ? DRM_XE_VM_CREATE_FLAG_FAULT_MODE : 0;
vm = xe_eudebug_client_vm_create(priv->c, fd, vm_flags, 0);
/* init uf_sync */
fence_data = aligned_alloc(xe_get_default_alignment(fd), sizeof(*fence_data));
igt_assert(fence_data);
uf_sync.timeline_value = 1337;
igt_debug("Run on: %s%u\n", xe_engine_class_string(priv->hwe->engine_class),
priv->hwe->engine_instance);
igt_until_timeout(5) {
struct drm_xe_ext_set_property eq_ext = {
.base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY,
.property = DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG,
.value = DRM_XE_EXEC_QUEUE_EUDEBUG_FLAG_ENABLE,
};
struct drm_xe_exec_queue_create eq_create = { 0 };
uint32_t clean_bo = 0;
uint32_t batch_bo = 0;
uint64_t clean_offset, batch_offset;
uint32_t exec_queue;
uint32_t *map, *cs;
uint64_t delta;
/* calculate offsets (vma addresses) */
batch_offset = (random() * SZ_2M) & (gtt_size - 1);
/* XXX: for some platforms/memory regions batch offset '0' can be problematic */
if (batch_offset == 0)
batch_offset = SZ_2M;
do {
clean_offset = (random() * SZ_2M) & (gtt_size - 1);
if (clean_offset == 0)
clean_offset = SZ_2M;
} while (clean_offset == batch_offset);
batch_offset += random() % SZ_2M & -bo_size;
clean_offset += random() % SZ_2M & -bo_size;
delta = (random() % bo_size) & -4;
uf_sync.addr = to_user_pointer(fence_data);
/* prepare clean bo */
clean_bo = xe_bo_create(fd, vm, bo_size, priv->region,
DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
memset(fence_data, 0, sizeof(*fence_data));
xe_eudebug_client_vm_bind_flags(priv->c, fd, vm, clean_bo, 0, clean_offset, bo_size,
0, &uf_sync, 1, 0);
xe_wait_ufence(fd, fence_data, uf_sync.timeline_value, 0,
XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * NSEC_PER_SEC);
/* prepare batch bo */
batch_bo = xe_bo_create(fd, vm, bo_size, priv->region,
DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
memset(fence_data, 0, sizeof(*fence_data));
xe_eudebug_client_vm_bind_flags(priv->c, fd, vm, batch_bo, 0, batch_offset, bo_size,
0, &uf_sync, 1, 0);
xe_wait_ufence(fd, fence_data, uf_sync.timeline_value, 0,
XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * NSEC_PER_SEC);
map = xe_bo_map(fd, batch_bo, bo_size);
cs = map;
*cs++ = MI_NOOP | 0xc5a3;
*cs++ = MI_LOAD_REGISTER_MEM_CMD | MI_LRI_LRM_CS_MMIO | 2;
*cs++ = CS_GPR0;
*cs++ = clean_offset + delta;
*cs++ = (clean_offset + delta) >> 32;
*cs++ = MI_STORE_REGISTER_MEM_CMD | MI_LRI_LRM_CS_MMIO | 2;
*cs++ = CS_GPR0;
*cs++ = batch_offset;
*cs++ = batch_offset >> 32;
*cs++ = MI_BATCH_BUFFER_END;
/* execute batch */
eq_create.width = 1;
eq_create.num_placements = 1;
eq_create.vm_id = vm;
eq_create.instances = to_user_pointer(priv->hwe);
eq_create.extensions = to_user_pointer(&eq_ext);
exec_queue = xe_eudebug_client_exec_queue_create(priv->c, fd, &eq_create);
uf_sync.addr = (cs - map) * 4 + batch_offset;
xe_exec_sync(fd, exec_queue, batch_offset, &uf_sync, 1);
xe_wait_ufence(fd, (uint64_t *)cs, uf_sync.timeline_value, exec_queue,
XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * NSEC_PER_SEC);
igt_assert_eq(*map, 0);
/* cleanup */
xe_eudebug_client_exec_queue_destroy(priv->c, fd, &eq_create);
munmap(map, bo_size);
xe_eudebug_client_vm_unbind(priv->c, fd, vm, 0, batch_offset, bo_size);
gem_close(fd, batch_bo);
xe_eudebug_client_vm_unbind(priv->c, fd, vm, 0, clean_offset, bo_size);
gem_close(fd, clean_bo);
count++;
}
priv->sum = count;
free(fence_data);
xe_eudebug_client_close_driver(priv->c, fd);
return NULL;
}
static void vm_bind_clear_client(struct xe_eudebug_client *c)
{
int fd = xe_eudebug_client_open_driver(c);
struct xe_device *xe_dev = xe_device_get(fd);
int count = xe_number_engines(fd) * xe_dev->mem_regions->num_mem_regions;
uint64_t memreg = all_memory_regions(fd);
struct vm_bind_clear_priv *priv = c->ptr;
int current = 0;
struct drm_xe_engine_class_instance *engine;
struct vm_bind_clear_thread_priv *threads;
uint64_t region;
threads = calloc(count, sizeof(*threads));
igt_assert(threads);
priv->sum = 0;
xe_for_each_mem_region(fd, memreg, region) {
xe_eudebug_for_each_engine(fd, engine) {
threads[current].c = c;
threads[current].hwe = engine;
threads[current].region = region;
pthread_create(&threads[current].thread, NULL,
vm_bind_clear_thread, &threads[current]);
current++;
}
}
for (current = 0; current < count; current++)
pthread_join(threads[current].thread, NULL);
xe_for_each_mem_region(fd, memreg, region) {
unsigned long sum = 0;
for (current = 0; current < count; current++)
if (threads[current].region == region)
sum += threads[current].sum;
igt_info("%s sampled %lu objects\n", xe_region_name(region), sum);
priv->sum += sum;
}
free(threads);
xe_device_put(fd);
xe_eudebug_client_close_driver(c, fd);
}
static void vm_bind_clear_test_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_op *eo = (void *)e;
struct vm_bind_clear_priv *priv = d->ptr;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
if (random() & 1) {
struct drm_xe_eudebug_vm_open vo = { 0, };
uint32_t v = 0xc1c1c1c1;
struct drm_xe_eudebug_event_vm_bind *eb;
int fd, delta, r;
igt_debug("vm bind op event received with ref %lld, addr 0x%llx, range 0x%llx\n",
eo->vm_bind_ref_seqno, eo->addr, eo->range);
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, eo->vm_bind_ref_seqno);
igt_assert(eb);
vo.client_handle = eb->client_handle;
vo.vm_handle = eb->vm_handle;
fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
igt_assert_lte(0, fd);
delta = (random() % eo->range) & -4;
r = pread(fd, &v, sizeof(v), eo->addr + delta);
igt_assert_eq(r, sizeof(v));
igt_assert_eq_u32(v, 0);
close(fd);
}
priv->bind_count++;
}
if (e->flags & DRM_XE_EUDEBUG_EVENT_DESTROY)
priv->unbind_count++;
}
static void vm_bind_clear_ack_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_ufence *ef = (void *)e;
xe_eudebug_ack_ufence(d->fd, ef);
}
/**
* SUBTEST: vm-bind-clear
* Functionality: memory access
* Description:
* Check that fresh buffers we vm_bind into the ppGTT are always clear.
*
* SUBTEST: vm-bind-clear-faultable
* Functionality: memory access with FAULTABLE_VM
* Description:
* Fault variation of test vm-bind-clear.
*/
static void test_vm_bind_clear(int fd, uint32_t flags)
{
struct vm_bind_clear_priv *priv;
struct xe_eudebug_session *s;
igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
priv = vm_bind_clear_priv_create();
s = xe_eudebug_session_create(fd, vm_bind_clear_client, flags, priv);
xe_eudebug_debugger_add_trigger(s->debugger, DRM_XE_EUDEBUG_EVENT_VM_BIND_OP,
vm_bind_clear_test_trigger);
xe_eudebug_debugger_add_trigger(s->debugger, DRM_XE_EUDEBUG_EVENT_VM_BIND_UFENCE,
vm_bind_clear_ack_trigger);
igt_assert_eq(xe_eudebug_debugger_attach(s->debugger, s->client), 0);
xe_eudebug_debugger_start_worker(s->debugger);
xe_eudebug_client_start(s->client);
xe_eudebug_client_wait_done(s->client);
xe_eudebug_debugger_stop_worker(s->debugger, 1);
igt_assert_eq(priv->bind_count, priv->unbind_count);
igt_assert_eq(priv->sum * 2, priv->bind_count);
xe_eudebug_session_destroy(s);
vm_bind_clear_priv_destroy(priv);
}
#define UFENCE_CLIENT_VM_TEST_VAL_START 0xaaaaaaaa
#define UFENCE_CLIENT_VM_TEST_VAL_END 0xbbbbbbbb
static void vma_ufence_client(struct xe_eudebug_client *c)
{
const unsigned int n = UFENCE_EVENT_COUNT_EXPECTED;
int fd = xe_eudebug_client_open_driver(c);
struct ufence_bind *binds = create_binds_with_ufence(fd, n);
uint32_t vm_flags = DRM_XE_VM_CREATE_FLAG_LR_MODE;
size_t bo_size = xe_get_default_alignment(fd);
uint64_t items = bo_size / sizeof(uint32_t);
uint32_t bo[UFENCE_EVENT_COUNT_EXPECTED];
uint32_t *ptr[UFENCE_EVENT_COUNT_EXPECTED];
uint32_t vm;
vm_flags |= (c->flags & TEST_FAULTABLE) ? DRM_XE_VM_CREATE_FLAG_FAULT_MODE : 0;
vm = xe_eudebug_client_vm_create(c, fd, vm_flags, 0);
for (int i = 0; i < n; i++) {
bo[i] = xe_bo_create(fd, 0, bo_size,
system_memory(fd), 0);
ptr[i] = xe_bo_map(fd, bo[i], bo_size);
igt_assert(ptr[i]);
memset(ptr[i], UFENCE_CLIENT_VM_TEST_VAL_START, bo_size);
}
for (int i = 0; i < n; i++) {
struct ufence_bind *b = &binds[i];
xe_eudebug_client_vm_bind_flags(c, fd, vm, bo[i], 0, b->addr, b->range, 0,
&b->f, 1, 0);
}
/* Wait for acks on ufences */
for (int i = 0; i < n; i++) {
int err;
int64_t timeout_ns;
struct ufence_bind *b = &binds[i];
timeout_ns = XE_EUDEBUG_DEFAULT_TIMEOUT_SEC * NSEC_PER_SEC;
err = __xe_wait_ufence(fd, &b->fence_data->vm_sync, b->f.timeline_value,
0, &timeout_ns);
igt_assert_eq(err, 0);
igt_assert_eq(b->fence_data->vm_sync, b->f.timeline_value);
igt_debug("wait #%d completed\n", i);
for (int j = 0; j < items; j++)
igt_assert_eq(ptr[i][j], UFENCE_CLIENT_VM_TEST_VAL_END);
}
for (int i = 0; i < n; i++) {
struct ufence_bind *b = &binds[i];
xe_eudebug_client_vm_unbind(c, fd, vm, 0, b->addr, b->range);
}
destroy_binds_with_ufence(binds, n);
for (int i = 0; i < n; i++) {
munmap(ptr[i], bo_size);
gem_close(fd, bo[i]);
}
xe_eudebug_client_vm_destroy(c, fd, vm);
xe_eudebug_client_close_driver(c, fd);
}
static void debugger_test_vma_ufence(struct xe_eudebug_debugger *d,
uint64_t client_handle,
uint64_t vm_handle,
uint64_t va_start,
uint64_t va_length)
{
struct drm_xe_eudebug_vm_open vo = { 0, };
uint32_t *v1, *v2;
uint32_t items = va_length / sizeof(uint32_t);
int fd;
int r, i;
v1 = malloc(va_length);
igt_assert(v1);
v2 = malloc(va_length);
igt_assert(v2);
vo.client_handle = client_handle;
vo.vm_handle = vm_handle;
fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
igt_assert_lte(0, fd);
r = pread(fd, v1, va_length, va_start);
igt_assert_eq(r, va_length);
for (i = 0; i < items; i++)
igt_assert_eq(v1[i], UFENCE_CLIENT_VM_TEST_VAL_START);
memset(v1, UFENCE_CLIENT_VM_TEST_VAL_END, va_length);
r = pwrite(fd, v1, va_length, va_start);
igt_assert_eq(r, va_length);
lseek(fd, va_start, SEEK_SET);
r = read(fd, v2, va_length);
igt_assert_eq(r, va_length);
for (i = 0; i < items; i++)
igt_assert_eq_u64(v1[i], v2[i]);
fsync(fd);
close(fd);
free(v1);
free(v2);
}
static void vma_ufence_op_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_op *eo = (void *)e;
struct ufence_priv *priv = d->ptr;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
char event_str[XE_EUDEBUG_EVENT_STRING_MAX_LEN];
struct drm_xe_eudebug_event_vm_bind *eb;
unsigned int op_count = priv->vm_bind_op_count++;
xe_eudebug_event_to_str(e, event_str, XE_EUDEBUG_EVENT_STRING_MAX_LEN);
igt_debug("vm bind op event: ref %lld, addr 0x%llx, range 0x%llx, op_count %u\n",
eo->vm_bind_ref_seqno,
eo->addr,
eo->range,
op_count);
igt_debug("vm bind op event received: %s\n", event_str);
xe_eudebug_assert(d, eo->vm_bind_ref_seqno);
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, eo->vm_bind_ref_seqno);
xe_eudebug_assert_f(d, eb, "vm bind event with seqno (%lld) not found\n",
eo->vm_bind_ref_seqno);
xe_eudebug_assert_f(d, eb->flags & DRM_XE_EUDEBUG_EVENT_VM_BIND_FLAG_UFENCE,
"vm bind event does not have ufence: %s\n", event_str);
priv->ufence_event_seqno[op_count] = eo->vm_bind_ref_seqno;
priv->ufence_event_vm_addr_start[op_count] = eo->addr;
priv->ufence_event_vm_addr_range[op_count] = eo->range;
}
}
static void vma_ufence_trigger(struct xe_eudebug_debugger *d,
struct drm_xe_eudebug_event *e)
{
struct drm_xe_eudebug_event_vm_bind_ufence *ef = (void *)e;
struct ufence_priv *priv = d->ptr;
unsigned int ufence_count = priv->ufence_event_count;
if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
char event_str[XE_EUDEBUG_EVENT_STRING_MAX_LEN];
struct drm_xe_eudebug_event_vm_bind *eb;
uint64_t addr = priv->ufence_event_vm_addr_start[ufence_count];
uint64_t range = priv->ufence_event_vm_addr_range[ufence_count];
xe_eudebug_event_to_str(e, event_str, XE_EUDEBUG_EVENT_STRING_MAX_LEN);
igt_debug("ufence event received: %s\n", event_str);
xe_eudebug_assert_f(d, priv->ufence_event_count < UFENCE_EVENT_COUNT_EXPECTED,
"surplus ufence event received: %s\n", event_str);
xe_eudebug_assert(d, ef->vm_bind_ref_seqno);
memcpy(&priv->ufence_events[priv->ufence_event_count++], ef, sizeof(*ef));
eb = (struct drm_xe_eudebug_event_vm_bind *)
xe_eudebug_event_log_find_seqno(d->log, ef->vm_bind_ref_seqno);
xe_eudebug_assert_f(d, eb, "vm bind event with seqno (%lld) not found\n",
ef->vm_bind_ref_seqno);
xe_eudebug_assert_f(d, eb->flags & DRM_XE_EUDEBUG_EVENT_VM_BIND_FLAG_UFENCE,
"vm bind event does not have ufence: %s\n", event_str);
igt_debug("vm bind ufence event received with ref %lld, addr 0x%" PRIu64 ", range 0x%" PRIu64 "\n",
ef->vm_bind_ref_seqno,
addr,
range);
debugger_test_vma_ufence(d, eb->client_handle, eb->vm_handle,
addr, range);
xe_eudebug_ack_ufence(d->fd, ef);
}
}
/**
* SUBTEST: vma-ufence
* Functionality: check ufence blocking
* Description:
* Intercept vm bind after receiving ufence event, then access target vm and write to it.
* Then check on client side if the write was successful.
*
* SUBTEST: vma-ufence-faultable
* Functionality: check ufence blocking with FAULTABLE_VM
* Description:
* Fault variation of test vma-ufence.
*/
static void test_vma_ufence(int fd, unsigned int flags)
{
struct xe_eudebug_session *s;
struct ufence_priv *priv;
igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
priv = ufence_priv_create();
s = xe_eudebug_session_create(fd, vma_ufence_client, flags, priv);
xe_eudebug_debugger_add_trigger(s->debugger,
DRM_XE_EUDEBUG_EVENT_VM_BIND_OP,
vma_ufence_op_trigger);
xe_eudebug_debugger_add_trigger(s->debugger,
DRM_XE_EUDEBUG_EVENT_VM_BIND_UFENCE,
vma_ufence_trigger);
igt_assert_eq(xe_eudebug_debugger_attach(s->debugger, s->client), 0);
xe_eudebug_debugger_start_worker(s->debugger);
xe_eudebug_client_start(s->client);
xe_eudebug_client_wait_done(s->client);
xe_eudebug_debugger_stop_worker(s->debugger, 1);
xe_eudebug_event_log_print(s->debugger->log, true);
xe_eudebug_event_log_print(s->client->log, true);
xe_eudebug_session_check(s, true, XE_EUDEBUG_FILTER_EVENT_VM_BIND_UFENCE);
xe_eudebug_session_destroy(s);
ufence_priv_destroy(priv);
}
/**
* SUBTEST: basic-exec-queues-enable
* Functionality: exec queues events
* Description:
* Test the exec queue property of enabling eudebug
*/
static void test_basic_exec_queues_enable(int fd)
{
struct drm_xe_engine_class_instance *hwe;
struct drm_xe_ext_set_property eq_ext = {
.base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY,
.property = DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG,
.value = 0,
};
const uint64_t success_value = DRM_XE_EXEC_QUEUE_EUDEBUG_FLAG_ENABLE;
const uint64_t ext = to_user_pointer(&eq_ext);
uint32_t vm_non_lr, vm_lr;
vm_non_lr = xe_vm_create(fd, 0, 0);
igt_assert_lte(0, vm_non_lr);
vm_lr = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
igt_assert_lte(0, vm_lr);
xe_for_each_engine(fd, hwe) {
uint32_t id;
int ret, i;
for (i = 0; i <= 64; i++) {
if (i == 0)
eq_ext.value = 0;
else
eq_ext.value = (1 << (i - 1));
ret = __xe_exec_queue_create(fd, vm_lr, 1, 1,
hwe, ext, &id);
if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COMPUTE &&
hwe->engine_class != DRM_XE_ENGINE_CLASS_RENDER) {
igt_assert_eq(ret, -EINVAL);
continue;
}
if (eq_ext.value == success_value) {
igt_assert_lte(0, ret);
xe_exec_queue_destroy(fd, id);
/* Wrong type of vm */
ret = __xe_exec_queue_create(fd, vm_non_lr, 1, 1,
hwe, ext, &id);
igt_assert_eq(ret, -EINVAL);
xe_eudebug_enable(fd, false);
ret = __xe_exec_queue_create(fd, vm_lr, 1, 1,
hwe, ext, &id);
igt_assert_eq(ret, -EPERM);
xe_eudebug_enable(fd, true);
} else {
igt_assert_eq(ret, -EINVAL);
}
}
}
xe_vm_destroy(fd, vm_lr);
xe_vm_destroy(fd, vm_non_lr);
}
igt_main
{
bool was_enabled;
bool *multigpu_was_enabled;
int fd, gpu_count;
igt_fixture {
fd = drm_open_driver(DRIVER_XE);
was_enabled = xe_eudebug_enable(fd, true);
igt_install_exit_handler(igt_drm_debug_mask_reset_exit_handler);
update_debug_mask_if_ci(DRM_UT_KMS);
}
igt_subtest("sysfs-toggle")
test_sysfs_toggle(fd);
igt_subtest("basic-connect")
test_connect(fd);
igt_subtest("connect-user")
test_connect_user(fd);
igt_subtest("basic-close")
test_close(fd);
igt_subtest("basic-read-event")
test_read_event(fd);
igt_subtest("basic-client")
test_basic_sessions(fd, 0, 1, true);
igt_subtest("basic-client-th")
test_basic_sessions_th(fd, 0, 1, true);
igt_subtest_group {
uint32_t flags[] = {0, TEST_FAULTABLE};
const char *suffix[] = {"", "-faultable"};
for (int i = 0; i < ARRAY_SIZE(flags); i++) {
igt_subtest_f("basic-vm-access%s", suffix[i])
test_vm_access(fd, flags[i], 1);
igt_subtest_f("basic-vm-access-userptr%s", suffix[i])
test_vm_access(fd, VM_BIND_OP_MAP_USERPTR | flags[i], 1);
igt_subtest_f("basic-vm-access-parameters%s", suffix[i])
test_vm_access_parameters(fd, flags[i], 1);
igt_subtest_f("basic-vm-access-parameters-userptr%s", suffix[i])
test_vm_access_parameters(fd, VM_BIND_OP_MAP_USERPTR | flags[i], 1);
igt_subtest_f("vma-ufence%s", suffix[i])
test_vma_ufence(fd, flags[i]);
igt_subtest_f("vm-bind-clear%s", suffix[i])
test_vm_bind_clear(fd, flags[i]);
}
}
igt_subtest("multiple-sessions")
test_basic_sessions(fd, CREATE_VMS | CREATE_EXEC_QUEUES, 4, true);
igt_subtest("basic-vms")
test_basic_sessions(fd, CREATE_VMS, 1, true);
igt_subtest("basic-exec-queues-enable")
test_basic_exec_queues_enable(fd);
igt_subtest("basic-exec-queues")
test_basic_sessions(fd, CREATE_EXEC_QUEUES, 1, true);
igt_subtest("basic-vm-bind")
test_basic_sessions(fd, VM_BIND, 1, true);
igt_subtest("basic-vm-bind-ufence")
test_basic_ufence(fd, 0);
igt_subtest("basic-vm-bind-ufence-delay-ack")
test_basic_ufence(fd, VM_BIND_DELAY_UFENCE_ACK);
igt_subtest("basic-vm-bind-ufence-reconnect")
test_basic_ufence(fd, VM_BIND_UFENCE_RECONNECT);
igt_subtest("basic-vm-bind-ufence-sigint-client")
test_basic_ufence(fd, VM_BIND_UFENCE_SIGINT_CLIENT);
igt_subtest("basic-vm-bind-discovery")
test_basic_discovery(fd, VM_BIND, true);
igt_subtest("basic-vm-bind-metadata-discovery")
test_basic_discovery(fd, VM_BIND_METADATA, true);
igt_subtest("basic-vm-bind-vm-destroy")
test_basic_sessions(fd, VM_BIND_VM_DESTROY, 1, false);
igt_subtest("basic-vm-bind-vm-destroy-discovery")
test_basic_discovery(fd, VM_BIND_VM_DESTROY, false);
igt_subtest("basic-vm-bind-extended")
test_basic_sessions(fd, VM_BIND_EXTENDED, 1, true);
igt_subtest("basic-vm-bind-extended-discovery")
test_basic_discovery(fd, VM_BIND_EXTENDED, true);
igt_subtest("read-metadata")
test_metadata_read(fd, 0, 1);
igt_subtest("attach-debug-metadata")
test_metadata_attach(fd, 0, 1);
igt_subtest("discovery-race")
test_race_discovery(fd, 0, 4);
igt_subtest("discovery-race-vmbind")
test_race_discovery(fd, DISCOVERY_VM_BIND, 4);
igt_subtest("discovery-race-sigint")
test_race_discovery(fd, DISCOVERY_SIGINT, 1);
igt_subtest("discovery-empty")
test_empty_discovery(fd, DISCOVERY_CLOSE_CLIENT, 16);
igt_subtest("discovery-empty-clients")
test_empty_discovery(fd, DISCOVERY_DESTROY_RESOURCES, 16);
igt_fixture {
xe_eudebug_enable(fd, was_enabled);
drm_close_driver(fd);
}
igt_subtest_group {
igt_fixture {
gpu_count = drm_prepare_filtered_multigpu(DRIVER_XE);
multigpu_was_enabled = malloc(gpu_count * sizeof(bool));
igt_assert(multigpu_was_enabled);
for (int i = 0; i < gpu_count; i++) {
fd = drm_open_filtered_card(i);
multigpu_was_enabled[i] = xe_eudebug_enable(fd, true);
close(fd);
}
}
igt_subtest("multigpu-basic-client") {
igt_require(gpu_count >= 2);
igt_multi_fork(child, gpu_count) {
fd = drm_open_filtered_card(child);
igt_assert_f(fd > 0, "cannot open gpu-%d, errno=%d\n",
child, errno);
igt_assert(is_xe_device(fd));
test_basic_sessions(fd, 0, 1, true);
close(fd);
}
igt_waitchildren();
}
igt_subtest("multigpu-basic-client-many") {
igt_require(gpu_count >= 2);
igt_multi_fork(child, gpu_count) {
fd = drm_open_filtered_card(child);
igt_assert_f(fd > 0, "cannot open gpu-%d, errno=%d\n",
child, errno);
igt_assert(is_xe_device(fd));
test_basic_sessions(fd, 0, 4, true);
close(fd);
}
igt_waitchildren();
}
igt_fixture {
for (int i = 0; i < gpu_count; i++) {
fd = drm_open_filtered_card(i);
xe_eudebug_enable(fd, multigpu_was_enabled[i]);
close(fd);
}
free(multigpu_was_enabled);
}
}
}
|