Merge branch 'master' of github.com:ckolivas/cgminer
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
diff --git a/API-README b/API-README
index 076785c..835ab24 100644
--- a/API-README
+++ b/API-README
@@ -482,6 +482,10 @@ api-example.php - a php script to access the API
You must modify the line "$socket = getsock('127.0.0.1', 4028);" at the
beginning of "function request($cmd)" to change where it looks for cgminer
+api-example.rb - a Ruby script to access the API.
+ usage: ruby api-example.rb command[:parameter] [HOST [PORT]]
+This script prints the parsed cgminer API response
+
API.java/API.class
a java program to access the API (with source code)
usAge is: java API command address port
diff --git a/ASIC-README b/ASIC-README
index e68837c..648142f 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -234,7 +234,11 @@ ASIC SPECIFIC COMMANDS
--hfa-temp-overheat <arg> Set the hashfast overheat throttling temperature (default: 95)
--hfa-temp-target <arg> Set the hashfast target temperature (0 to disable) (default: 88)
--klondike-options <arg> Set klondike options clock:temptarget
+--minion-chipreport <arg> Seconds to report chip 5min hashrate, range 0-100 (default: 0=disabled)
--minion-freq <arg> Set minion chip frequencies in MHz, single value or comma list, range 100-1400 (default: 1000)
+--minion-idlecount Report when IdleCount is >0 or changes
+--minion-overheat Enable directly halting any chip when the status exceeds 100C
+--minion-temp <arg> Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)
--nfu-bits <arg> Set nanofury bits for overclocking, range 32-63 (default: 50)
diff --git a/README b/README
index c3eb8d6..55f6b2b 100644
--- a/README
+++ b/README
@@ -218,7 +218,11 @@ Options for both config file and command line:
--load-balance Change multipool strategy from failover to quota based balance
--log|-l <arg> Interval in seconds between log output (default: 5)
--lowmem Minimise caching of shares for low memory applications
+--minion-chipreport <arg> Seconds to report chip 5min hashrate, range 0-100 (default: 0=disabled)
--minion-freq <arg> Set minion chip frequencies in MHz, single value or comma list, range 100-1400 (default: 1000)
+--minion-idlecount Report when IdleCount is >0 or changes
+--minion-overheat Enable directly halting any chip when the status exceeds 100C
+--minion-temp <arg> Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)
--monitor|-m <arg> Use custom pipe cmd for output messages
--nfu-bits <arg> Set nanofury bits for overclocking, range 32-63 (default: 50)
--net-delay Impose small delays in networking to not overload slow routers
diff --git a/cgminer.c b/cgminer.c
index c3da2de..63a9b07 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -239,7 +239,12 @@ static char *opt_set_hfa_fan;
#endif
static char *opt_set_null;
#ifdef USE_MINION
+int opt_minion_chipreport;
+char *opt_minion_cores;
char *opt_minion_freq;
+bool opt_minion_idlecount;
+bool opt_minion_overheat;
+char *opt_minion_temp;
#endif
#ifdef USE_USBUTILS
@@ -1316,9 +1321,24 @@ static struct opt_table opt_config_table[] = {
opt_set_bool, &opt_lowmem,
"Minimise caching of shares for low memory applications"),
#ifdef USE_MINION
+ OPT_WITH_ARG("--minion-chipreport",
+ set_int_0_to_100, opt_show_intval, &opt_minion_chipreport,
+ "Seconds to report chip 5min hashrate, range 0-100 (default: 0=disabled)"),
OPT_WITH_ARG("--minion-freq",
opt_set_charp, NULL, &opt_minion_freq,
"Set minion chip frequencies in MHz, single value or comma list, range 100-1400 (default: 1000)"),
+ OPT_WITH_ARG("--minion-cores",
+ opt_set_charp, NULL, &opt_minion_cores,
+ opt_hidden),
+ OPT_WITHOUT_ARG("--minion-idlecount",
+ opt_set_bool, &opt_minion_idlecount,
+ "Report when IdleCount is >0 or changes"),
+ OPT_WITHOUT_ARG("--minion-overheat",
+ opt_set_bool, &opt_minion_overheat,
+ "Enable directly halting any chip when the status exceeds 100C"),
+ OPT_WITH_ARG("--minion-temp",
+ opt_set_charp, NULL, &opt_minion_temp,
+ "Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)"),
#endif
#if defined(unix) || defined(__APPLE__)
OPT_WITH_ARG("--monitor|-m",
diff --git a/driver-bitmain.h b/driver-bitmain.h
index be066c1..e3f19a7 100644
--- a/driver-bitmain.h
+++ b/driver-bitmain.h
@@ -40,7 +40,7 @@
#define BITMAIN_TEMP_TARGET 50
#define BITMAIN_TEMP_HYSTERESIS 3
-#define BITMAIN_TEMP_OVERHEAT 60
+#define BITMAIN_TEMP_OVERHEAT 75
#define BITMAIN_DEFAULT_TIMEOUT 0x2D
#define BITMAIN_MIN_FREQUENCY 10
diff --git a/driver-minion.c b/driver-minion.c
index cc39908..736ee61 100644
--- a/driver-minion.c
+++ b/driver-minion.c
@@ -10,6 +10,7 @@
#include "config.h"
#include "compat.h"
#include "miner.h"
+#include "klist.h"
#include <ctype.h>
#include <math.h>
@@ -26,21 +27,31 @@ static void minion_detect(__maybe_unused bool hotplug)
#include <fcntl.h>
#include <poll.h>
+// Define this to 1 to enable interrupt code and enable no_nonce
+#define ENABLE_INT_NONO 0
+
+// The code is always in - this just decides if it does it
+static bool minreread = true;
+
#define MINION_SPI_BUS 0
#define MINION_SPI_CHIP 0
-#define MINION_SPI_SPEED 2000000
+//#define MINION_SPI_SPEED 2000000
+#define MINION_SPI_SPEED 100000
#define MINION_SPI_BUFSIZ 1024
#define MINION_CHIPS 32
#define MINION_CORES 99
+#define FAKE_CORE MINION_CORES
/*
* TODO: These will need adjusting for final hardware
* Look them up and calculate them?
*/
-#define MINION_QUE_HIGH 42
-#define MINION_QUE_LOW 2
+#define MINION_QUE_MAX 64
+#define MINION_QUE_HIGH 64
+#define MINION_QUE_SEND 16
+#define MINION_QUE_LOW 8
#define MINION_FFL " - from %s %s() line %d"
#define MINION_FFL_HERE __FILE__, __func__, __LINE__
@@ -74,6 +85,10 @@ static void minion_detect(__maybe_unused bool hotplug)
#define MINION_SYS_FIFO_STA 0x0b
#define MINION_SYS_QUE_TRIG 0x0c
#define MINION_SYS_BUF_TRIG 0x0d
+#define MINION_SYS_IDLE_CNT 0x0e
+
+// How many 32 bit reports make up all the cores - 99 cores = 4 reps
+#define MINION_CORE_REPS (int)((((MINION_CORES-1) >> 5) & 0xff) + 1)
// All SYS data sizes are DATA_SIZ
#define MINION_SYS_SIZ DATA_SIZ
@@ -130,9 +145,14 @@ static void minion_detect(__maybe_unused bool hotplug)
RSTN_CTL_SPI_SW_RSTN | \
RSTN_CTL_FLUSH_CMD_QUEUE)
+#if ENABLE_INT_NONO
// enable 'no nonce' report
#define SYS_MISC_CTL_DEFAULT 0x04
+#else
+#define SYS_MISC_CTL_DEFAULT 0x00
+#endif
+// Temperature returned by MINION_SYS_CHIP_STA 0x01 STA_TEMP()
#define MINION_TEMP_40 0
#define MINION_TEMP_60 1
#define MINION_TEMP_80 3
@@ -146,6 +166,23 @@ static const char *min_temp_100 = "80-100";
static const char *min_temp_over = ">100";
static const char *min_temp_invalid = "?";
+/*
+ * Temperature for MINION_SYS_TEMP_CTL 0x03 temp_thres [0:3]
+ * i.e. it starts at 120 and goes up in steps of 5 to 160
+ */
+#define MINION_TEMP_CTL_MIN 1
+#define MINION_TEMP_CTL_MAX 9
+#define MINION_TEMP_CTL_BITS 0x0f
+#define MINION_TEMP_CTL_DEF 135
+#define MINION_TEMP_CTL_STEP 5
+#define MINION_TEMP_CTL_MIN_VALUE 120
+#define MINION_TEMP_CTL_MAX_VALUE (MINION_TEMP_CTL_MIN_VALUE + \
+ (MINION_TEMP_CTL_STEP * \
+ (MINION_TEMP_CTL_MAX - MINION_TEMP_CTL_MIN)))
+#define MINION_TEMP_DISABLE "disable"
+#define MINION_TEMP_CTL_DISABLE -1
+#define MINION_TEMP_CTL_DISABLE_VALUE 0x20
+
// CORE data size is DATA_SIZ
#define MINION_CORE_ENA0_31 0x10
#define MINION_CORE_ENA32_63 0x11
@@ -159,6 +196,8 @@ static const char *min_temp_invalid = "?";
// All CORE data sizes are DATA_SIZ
#define MINION_CORE_SIZ DATA_SIZ
+#define MINION_CORE_ALL "all"
+
// RES data size is minion_result
#define MINION_RES_DATA 0x20
#define MINION_RES_PEEK 0x21
@@ -206,6 +245,7 @@ struct minion_header {
#define HSIZE() (sizeof(struct minion_header) - 4)
#define MINION_NOCHIP_SIG 0x00000000
+#define MINION_NOCHIP_SIG2 0xffffffff
#define MINION_CHIP_SIG 0xb1ac8a44
/*
@@ -250,6 +290,8 @@ static uint32_t minion_freq[] = {
0x210074 // 14 = 1400Mhz
};
+#define MINION_RESET_PERCENT 50.0
+
#define STA_TEMP(_sta) ((uint16_t)((_sta)[3] & 0x1f))
#define STA_CORES(_sta) ((uint16_t)((_sta)[2]))
#define STA_FREQ(_sta) ((uint32_t)((_sta)[1]) * 0x100 + (uint32_t)((_sta)[0]))
@@ -258,19 +300,37 @@ static uint32_t minion_freq[] = {
#define MINION_STATS_UPDATE_TIME_mS 1000
#define MINION_STATS_UPDATE_RAND_mS 1000
+// Don't report it more than once every ... 5s
+#define MINION_IDLE_MESSAGE_ms 5000
+
struct minion_status {
uint16_t temp;
uint16_t cores;
uint32_t freq;
+ uint32_t quework;
+ uint32_t chipwork;
+ uint32_t realwork; // chipwork, but FIFO_STA can update it
struct timeval last;
bool overheat;
+ bool islow;
+ bool tohigh;
+ int lowcount;
+ uint32_t freqsent;
+ uint32_t overheats;
+ struct timeval lastoverheat;
+ struct timeval lastrecover;
+ double overheattime;
+ uint32_t tempsent;
+ uint32_t idle;
+ uint32_t last_rpt_idle;
+ struct timeval idle_rpt;
};
-// TODO: untested/unused
-#define ENABLE_CORE(_core, _n) ((_core)->core[_n >> 4] |= (1 << (_n % 8)))
-#define CORE_IDLE(_core, _n) ((_core)->core[_n >> 4] & (1 << (_n % 8)))
+#define ENABLE_CORE(_core, _n) ((_core[_n >> 3]) |= (1 << (_n % 8)))
+#define CORE_IDLE(_core, _n) ((_core[_n >> 3]) & (1 << (_n % 8)))
#define FIFO_RES(_fifo, _off) ((_fifo)[(_off) + 0])
+#define FIFO_CMD(_fifo, _off) ((_fifo)[(_off) + 1])
#define RES_GOLD(_res) ((((_res)->status[3]) & 0x80) == 0)
#define RES_CHIP(_res) (((_res)->status[3]) & 0x1f)
@@ -348,6 +408,7 @@ struct minion_que {
#define MINION_SCAN_mS 88
#define ALLOC_WITEMS 4096
+#define LIMIT_WITEMS 0
typedef struct witem {
struct work *work;
@@ -355,13 +416,16 @@ typedef struct witem {
struct timeval sent;
int nonces;
bool urgent;
- bool stale; // if stale, don't decrement count_up when discarded
+ bool stale; // if stale, don't decrement que/chip/realwork when discarded
bool rolled;
+ int errors; // uncertain since the error could mean task_id is wrong
} WITEM;
#define ALLOC_TITEMS 256
+#define LIMIT_TITEMS 0
typedef struct titem {
+ uint64_t tid;
uint8_t chip;
bool write;
uint8_t address;
@@ -376,15 +440,18 @@ typedef struct titem {
bool urgent;
uint8_t work_state;
struct work *work;
+ K_ITEM *witem;
} TITEM;
#define ALLOC_RITEMS 256
+#define LIMIT_RITEMS 0
typedef struct ritem {
int chip;
int core;
uint32_t task_id;
uint32_t nonce;
+ struct timeval when;
/*
* Only once per task_id if no nonces were found
* Sent with core = 0
@@ -393,45 +460,29 @@ typedef struct ritem {
* see what the final hardware does (minor code performance gain)
*/
bool no_nonce;
+ // If we requested the result twice:
+ bool another;
+ uint32_t task_id2;
+ uint32_t nonce2;
} RITEM;
-typedef struct k_item {
- const char *name;
- struct k_item *prev;
- struct k_item *next;
- void *data;
-} K_ITEM;
+#define ALLOC_HITEMS 4096
+#define LIMIT_HITEMS 0
-#define DATAW(_item) ((WITEM *)(_item->data))
-#define DATAT(_item) ((TITEM *)(_item->data))
-#define DATAR(_item) ((RITEM *)(_item->data))
+// How much history to keep (5min)
+#define MINION_HISTORY_s 300
-typedef struct k_list {
- const char *name;
- bool is_store;
- cglock_t *lock;
- struct k_item *head;
- struct k_item *tail;
- size_t siz; // item data size
- int total; // total allocated
- int count; // in this list
- int count_up; // incremented every time one is added
- int allocate; // number to intially allocate and each time we run out
- bool do_tail; // store tail
-} K_LIST;
+// History must be always generated for the reset check
+#define MINION_MAX_RESET_CHECK 2
-/*
- * K_STORE is for a list of items taken from a K_LIST
- * The restriction is, a K_STORE must not allocate new items,
- * only the K_LIST should do that
- * i.e. all K_STORE items came from a K_LIST
- */
-#define K_STORE K_LIST
+typedef struct hitem {
+ struct timeval when;
+} HITEM;
-#define K_WLOCK(_list) cg_wlock(_list->lock)
-#define K_WUNLOCK(_list) cg_wunlock(_list->lock)
-#define K_RLOCK(_list) cg_rlock(_list->lock)
-#define K_RUNLOCK(_list) cg_runlock(_list->lock)
+#define DATAW(_item) ((WITEM *)(_item->data))
+#define DATAT(_item) ((TITEM *)(_item->data))
+#define DATAR(_item) ((RITEM *)(_item->data))
+#define DATAH(_item) ((HITEM *)(_item->data))
// Set this to 1 to enable iostats processing
// N.B. it slows down mining
@@ -561,18 +612,30 @@ struct minion_info {
int chips;
bool chip[MINION_CHIPS];
int init_freq[MINION_CHIPS];
+ int init_temp[MINION_CHIPS];
+ uint8_t init_cores[MINION_CHIPS][DATA_SIZ*MINION_CORE_REPS];
uint32_t next_task_id;
// Stats
uint64_t chip_nonces[MINION_CHIPS];
+ uint64_t chip_nononces[MINION_CHIPS];
uint64_t chip_good[MINION_CHIPS];
uint64_t chip_bad[MINION_CHIPS];
- uint64_t core_good[MINION_CHIPS][MINION_CORES];
- uint64_t core_bad[MINION_CHIPS][MINION_CORES];
+ uint64_t chip_err[MINION_CHIPS];
+ uint64_t core_good[MINION_CHIPS][MINION_CORES+1];
+ uint64_t core_bad[MINION_CHIPS][MINION_CORES+1];
+
+ uint32_t chip_core_ena[MINION_CORE_REPS][MINION_CHIPS];
+ uint32_t chip_core_act[MINION_CORE_REPS][MINION_CHIPS];
struct minion_status chip_status[MINION_CHIPS];
+ uint64_t interrupts;
+ uint64_t result_interrupts;
+ uint64_t command_interrupts;
+ char last_interrupt[64];
+
pthread_mutex_t nonce_lock;
uint64_t new_nonces;
@@ -583,9 +646,20 @@ struct minion_info {
uint64_t work_unrolled;
uint64_t work_rolled;
+ uint64_t spi_errors;
+ uint64_t chip_spi_errors[MINION_CHIPS];
+
+ uint64_t tasks_failed[MINION_CHIPS];
+ uint64_t tasks_recovered[MINION_CHIPS];
+ uint64_t nonces_failed[MINION_CHIPS];
+ uint64_t nonces_recovered[MINION_CHIPS];
+ struct timeval last_reset[MINION_CHIPS];
+ double do_reset[MINION_CHIPS];
+
// Work items
K_LIST *wfree_list;
K_STORE *wwork_list;
+ K_STORE *wque_list[MINION_CHIPS];
K_STORE *wchip_list[MINION_CHIPS];
// Task list
@@ -593,12 +667,25 @@ struct minion_info {
K_STORE *task_list;
K_STORE *treply_list;
+ uint64_t next_tid;
+
// Nonce replies
K_LIST *rfree_list;
K_STORE *rnonce_list;
struct timeval last_did;
+ // Nonce history
+ K_LIST *hfree_list;
+ K_STORE *hchip_list[MINION_CHIPS];
+
+ int history_gen;
+ struct timeval chip_chk;
+ struct timeval chip_rpt;
+ double history_ghs[MINION_CHIPS];
+ // Gets reset to zero each time it is used in reporting
+ int res_err_count[MINION_CHIPS];
+
#if DO_IO_STATS
// Total
IOSTAT summary;
@@ -611,173 +698,6 @@ struct minion_info {
bool initialised;
};
-static void alloc_items(K_LIST *list, MINION_FFL_ARGS)
-{
- K_ITEM *item;
- int i;
-
- if (list->is_store) {
- quithere(1, "List %s store can't %s" MINION_FFL,
- list->name, __func__, MINION_FFL_PASS);
- }
-
- item = calloc(list->allocate, sizeof(*item));
- if (!item) {
- quithere(1, "List %s failed to calloc %d new items - total was %d",
- list->name, list->allocate, list->total);
- }
-
- list->total += list->allocate;
- list->count = list->allocate;
- list->count_up = list->allocate;
-
- item[0].name = list->name;
- item[0].prev = NULL;
- item[0].next = &(item[1]);
- for (i = 1; i < list->allocate-1; i++) {
- item[i].name = list->name;
- item[i].prev = &item[i-1];
- item[i].next = &item[i+1];
- }
- item[list->allocate-1].name = list->name;
- item[list->allocate-1].prev = &(item[list->allocate-2]);
- item[list->allocate-1].next = NULL;
-
- list->head = item;
- if (list->do_tail)
- list->tail = &(item[list->allocate-1]);
-
- item = list->head;
- while (item) {
- item->data = calloc(1, list->siz);
- if (!(item->data))
- quithere(1, "List %s failed to calloc item data", list->name);
- item = item->next;
- }
-}
-
-static K_STORE *new_store(K_LIST *list)
-{
- K_STORE *store;
-
- store = calloc(1, sizeof(*store));
- if (!store)
- quithere(1, "Failed to calloc store for %s", list->name);
-
- store->is_store = true;
- store->lock = list->lock;
- store->name = list->name;
- store->do_tail = list->do_tail;
-
- return store;
-}
-
-static K_LIST *new_list(const char *name, size_t siz, int allocate, bool do_tail, MINION_FFL_ARGS)
-{
- K_LIST *list;
-
- if (allocate < 1)
- quithere(1, "Invalid new list %s with allocate %d must be > 0", name, allocate);
-
- list = calloc(1, sizeof(*list));
- if (!list)
- quithere(1, "Failed to calloc list %s", name);
-
- list->is_store = false;
-
- list->lock = calloc(1, sizeof(*(list->lock)));
- if (!(list->lock))
- quithere(1, "Failed to calloc lock for list %s", name);
-
- cglock_init(list->lock);
-
- list->name = name;
- list->siz = siz;
- list->allocate = allocate;
- list->do_tail = do_tail;
-
- alloc_items(list, MINION_FFL_PASS);
-
- return list;
-}
-
-static K_ITEM *k_get_head(K_LIST *list, MINION_FFL_ARGS)
-{
- K_ITEM *item;
-
- if (!(list->head))
- alloc_items(list, MINION_FFL_PASS);
-
- item = list->head;
- list->head = item->next;
- if (list->head)
- list->head->prev = NULL;
- else {
- if (list->do_tail)
- list->tail = NULL;
- }
-
- item->prev = item->next = NULL;
-
- list->count--;
-
- return item;
-}
-
-#define k_free_head k_add_head
-static void k_add_head(K_LIST *list, K_ITEM *item, MINION_FFL_ARGS)
-{
- if (item->name != list->name) {
- quithere(1, "List %s can't %s a %s item" MINION_FFL,
- list->name, __func__, item->name, MINION_FFL_PASS);
- }
-
- item->prev = NULL;
- item->next = list->head;
- if (list->head)
- list->head->prev = item;
-
- list->head = item;
-
- if (list->do_tail) {
- if (!(list->tail))
- list->tail = item;
- }
-
- list->count++;
- list->count_up++;
-}
-
-/*
-// TODO: remove later - it slows it down (of course) - only for debugging
-static void k_free_head(K_LIST *list, K_ITEM *item, MINION_FFL_ARGS)
-{
- memset(item->data, 0xff, list->siz);
- k_add_head(list, item, MINION_FFL_PASS);
-}
-*/
-
-static void k_remove(K_LIST *list, K_ITEM *item)
-{
- if (item->prev)
- item->prev->next = item->next;
-
- if (item->next)
- item->next->prev = item->prev;
-
- if (list->head == item)
- list->head = item->next;
-
- if (list->do_tail) {
- if (list->tail == item)
- list->tail = item->prev;
- }
-
- item->prev = item->next = NULL;
-
- list->count--;
-}
-
static void ready_work(struct cgpu_info *minioncgpu, struct work *work, bool rolled)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
@@ -785,7 +705,7 @@ static void ready_work(struct cgpu_info *minioncgpu, struct work *work, bool rol
K_WLOCK(minioninfo->wfree_list);
- item = k_get_head(minioninfo->wfree_list, MINION_FFL_HERE);
+ item = k_unlink_head(minioninfo->wfree_list);
DATAW(item)->work = work;
DATAW(item)->task_id = 0;
@@ -793,13 +713,16 @@ static void ready_work(struct cgpu_info *minioncgpu, struct work *work, bool rol
DATAW(item)->nonces = 0;
DATAW(item)->urgent = false;
DATAW(item)->rolled = rolled;
+ DATAW(item)->errors = 0;
- k_add_head(minioninfo->wwork_list, item, MINION_FFL_HERE);
+ k_add_head(minioninfo->wwork_list, item);
K_WUNLOCK(minioninfo->wfree_list);
}
-static bool oldest_nonce(struct cgpu_info *minioncgpu, int *chip, int *core, uint32_t *task_id, uint32_t *nonce, bool *no_nonce)
+static bool oldest_nonce(struct cgpu_info *minioncgpu, int *chip, int *core, uint32_t *task_id,
+ uint32_t *nonce, bool *no_nonce, struct timeval *when,
+ bool *another, uint32_t *task_id2, uint32_t *nonce2)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
K_ITEM *item = NULL;
@@ -807,19 +730,20 @@ static bool oldest_nonce(struct cgpu_info *minioncgpu, int *chip, int *core, uin
K_WLOCK(minioninfo->rnonce_list);
- item = minioninfo->rnonce_list->tail;
+ item = k_unlink_tail(minioninfo->rnonce_list);
if (item) {
- // unlink from res
- k_remove(minioninfo->rnonce_list, item);
-
found = true;
*chip = DATAR(item)->chip;
*core = DATAR(item)->core;
*task_id = DATAR(item)->task_id;
*nonce = DATAR(item)->nonce;
*no_nonce = DATAR(item)->no_nonce;
+ memcpy(when, &(DATAR(item)->when), sizeof(*when));
+ *another = DATAR(item)->another;
+ *task_id2 = DATAR(item)->task_id2;
+ *nonce2 = DATAR(item)->nonce2;
- k_free_head(minioninfo->rfree_list, item, MINION_FFL_HERE);
+ k_free_head(minioninfo->rfree_list, item);
}
K_WUNLOCK(minioninfo->rnonce_list);
@@ -893,6 +817,9 @@ static const char *addr2txt(uint8_t addr)
// For all other debug so it can easily be switched always on
#define MINION_LOG LOG_DEBUG
+// For task corruption logging
+#define MINTASK_LOG LOG_DEBUG
+
/*
static void display_ioctl(int reply, uint32_t osiz, uint8_t *obuf, uint32_t rsiz, uint8_t *rbuf)
{
@@ -1073,13 +1000,13 @@ static bool _minion_txrx(struct cgpu_info *minioncgpu, struct minion_info *minio
task->reply = do_ioctl(task->obuf, task->osiz, task->rbuf, task->rsiz);
if (task->reply < 0) {
- applog(LOG_ERR, "%s%d: ioctl failed reply=%d err=%d" MINION_FFL,
+ applog(LOG_ERR, "%s%d: chip=%d ioctl failed reply=%d err=%d" MINION_FFL,
minioncgpu->drv->name, minioncgpu->device_id,
- task->reply, errno, MINION_FFL_PASS);
+ task->chip, task->reply, errno, MINION_FFL_PASS);
} else if (task->reply < (int)(task->osiz)) {
- applog(LOG_ERR, "%s%d: ioctl failed to write %d only wrote %d (err=%d)" MINION_FFL,
+ applog(LOG_ERR, "%s%d: chip=%d ioctl failed to write %d only wrote %d (err=%d)" MINION_FFL,
minioncgpu->drv->name, minioncgpu->device_id,
- (int)(task->osiz), task->reply, errno, MINION_FFL_PASS);
+ task->chip, (int)(task->osiz), task->reply, errno, MINION_FFL_PASS);
}
return (task->reply >= (int)(task->osiz));
@@ -1169,99 +1096,75 @@ static void init_chip(struct cgpu_info *minioncgpu, struct minion_info *minionin
data[2] = (uint8_t)(((freq & 0xff0000) >> 16) & 0xff);
data[3] = (uint8_t)(((freq & 0xff000000) >> 24) & 0xff);
+ minioninfo->chip_status[chip].freqsent = freq;
+
reply = build_cmd(minioncgpu, minioninfo,
chip, WRITE_ADDR(MINION_SYS_FREQ_CTL),
rbuf, 0, data);
+
+ // Set temp threshold
+ choice = minioninfo->init_temp[chip];
+ if (choice == MINION_TEMP_CTL_DISABLE)
+ choice = MINION_TEMP_CTL_DISABLE_VALUE;
+ else {
+ if (choice < MINION_TEMP_CTL_MIN_VALUE || choice > MINION_TEMP_CTL_MAX_VALUE)
+ choice = MINION_TEMP_CTL_DEF;
+ choice -= MINION_TEMP_CTL_MIN_VALUE;
+ choice /= MINION_TEMP_CTL_STEP;
+ choice += MINION_TEMP_CTL_MIN;
+ if (choice < MINION_TEMP_CTL_MIN)
+ choice = MINION_TEMP_CTL_MIN;
+ if (choice > MINION_TEMP_CTL_MAX)
+ choice = MINION_TEMP_CTL_MAX;
+ }
+ data[0] = (uint8_t)choice;
+ data[1] = 0;
+ data[2] = 0;
+ data[3] = 0;
+
+ minioninfo->chip_status[chip].tempsent = choice;
+
+ reply = build_cmd(minioncgpu, minioninfo,
+ chip, WRITE_ADDR(MINION_SYS_TEMP_CTL),
+ rbuf, 0, data);
}
-// TODO: hard coded for now
static void enable_chip_cores(struct cgpu_info *minioncgpu, struct minion_info *minioninfo, int chip)
{
uint8_t rbuf[MINION_BUFSIZ];
uint8_t data[4];
__maybe_unused int reply;
+ int rep, i;
- data[0] = data[1] = data[2] = data[3] = 0x00;
-
- // First see what it reports as - results ignored for now
- reply = build_cmd(minioncgpu, minioninfo,
- chip, READ_ADDR(MINION_CORE_ENA0_31),
- rbuf, MINION_CORE_SIZ, data);
-
- reply = build_cmd(minioncgpu, minioninfo,
- chip, READ_ADDR(MINION_CORE_ENA32_63),
- rbuf, MINION_CORE_SIZ, data);
-
- reply = build_cmd(minioncgpu, minioninfo,
- chip, READ_ADDR(MINION_CORE_ENA64_95),
- rbuf, MINION_CORE_SIZ, data);
-
- reply = build_cmd(minioncgpu, minioninfo,
- chip, READ_ADDR(MINION_CORE_ENA96_98),
- rbuf, MINION_CORE_SIZ, data);
-
- /*
- * This will say it has completed the test 99 times faster than
- * a single core speed since all work will be divided up across all
- * 99 cores (even if they aren't there)
- * Of course it will only have checked N/99 of the nonce range
- * where N = the number of working cores
- */
- data[0] = 0xff;
- data[1] = 0xff;
- data[2] = 0xff;
- data[3] = 0xff;
-
- /*
- * there really is no reason to do this except in testing
- * since when mining with real data it will still mine at
- * full speed if using stratum (but not on getwork),
- * however if we are testing for specific results, not mining speed,
- * then it's necessary to force the nonce ranges on incomplete hardware
- *
- * TODO: consider handling getwork and calculating these if the number
- * of working cores isn't all of them? (and redoing if the number changes)
- * See the idle_cnt register ...
- */
-// data[0] = 0x02; // core 1
-// data[1] = 0x00;
-// data[2] = 0x00;
-// data[3] = 0x00;
+ for (i = 0; i < 4; i++)
+ data[i] = minioninfo->init_cores[chip][i];
reply = build_cmd(minioncgpu, minioninfo,
chip, WRITE_ADDR(MINION_CORE_ENA0_31),
rbuf, 0, data);
-// data[0] = 0x00;
-// data[1] = 0x00;
-// data[2] = 0x01; // core 48
-// data[2] = 0x00;
-// data[3] = 0x00;
+ for (i = 0; i < 4; i++)
+ data[i] = minioninfo->init_cores[chip][i+4];
reply = build_cmd(minioncgpu, minioninfo,
chip, WRITE_ADDR(MINION_CORE_ENA32_63),
rbuf, 0, data);
-// data[0] = 0x00;
-// data[1] = 0x00;
-// data[2] = 0x00;
-// data[3] = 0x00;
+ for (i = 0; i < 4; i++)
+ data[i] = minioninfo->init_cores[chip][i+8];
reply = build_cmd(minioncgpu, minioninfo,
chip, WRITE_ADDR(MINION_CORE_ENA64_95),
rbuf, 0, data);
- data[0] = 0x07; // core 96,97,98
-// data[0] = 0x04; // core 98
- data[1] = 0x00;
- data[2] = 0x00;
- data[3] = 0x00;
+ for (i = 0; i < 4; i++)
+ data[i] = minioninfo->init_cores[chip][i+12];
reply = build_cmd(minioncgpu, minioninfo,
chip, WRITE_ADDR(MINION_CORE_ENA96_98),
rbuf, 0, data);
-/* Use default
+/* Below is for testing - disabled/use default
// 1/3 range for each of the 3 cores
// data[0] = 0x55;
// data[1] = 0x55;
@@ -1307,9 +1210,36 @@ static void enable_chip_cores(struct cgpu_info *minioncgpu, struct minion_info *
chip, WRITE_ADDR(MINION_NONCE_START),
rbuf, 0, data);
*/
+
+ // store the core ena state
+ for (rep = 0; rep < MINION_CORE_REPS; rep++) {
+ data[0] = 0x0;
+ data[1] = 0x0;
+ data[2] = 0x0;
+ data[3] = 0x0;
+
+ reply = build_cmd(minioncgpu, minioninfo,
+ chip, READ_ADDR(MINION_CORE_ENA0_31 + rep),
+ rbuf, MINION_CORE_SIZ, data);
+
+ minioninfo->chip_core_ena[rep][chip] = *((uint32_t *)&(rbuf[HSIZE()]));
+ }
+
+ // store the core active state
+ for (rep = 0; rep < MINION_CORE_REPS; rep++) {
+ data[0] = 0x0;
+ data[1] = 0x0;
+ data[2] = 0x0;
+ data[3] = 0x0;
+
+ reply = build_cmd(minioncgpu, minioninfo,
+ chip, READ_ADDR(MINION_CORE_ACT0_31 + rep),
+ rbuf, MINION_CORE_SIZ, data);
+
+ minioninfo->chip_core_act[rep][chip] = *((uint32_t *)&(rbuf[HSIZE()]));
+ }
}
-// TODO: hard coded for now
static void enable_interrupt(struct cgpu_info *minioncgpu, struct minion_info *minioninfo, int chip)
{
uint8_t rbuf[MINION_BUFSIZ];
@@ -1325,7 +1255,9 @@ static void enable_interrupt(struct cgpu_info *minioncgpu, struct minion_info *m
chip, WRITE_ADDR(MINION_SYS_BUF_TRIG),
rbuf, 0, data);
- data[0] = MINION_QUE_HIGH; // spaces available ... i.e. empty
+// data[0] = MINION_QUE_MAX; // spaces available ... i.e. empty
+// data[0] = MINION_QUE_LOW; // spaces in use
+ data[0] = MINION_QUE_MAX - MINION_QUE_LOW; // spaces available
data[1] = 0x00;
data[2] = 0x00;
data[3] = 0x00;
@@ -1335,7 +1267,11 @@ static void enable_interrupt(struct cgpu_info *minioncgpu, struct minion_info *m
rbuf, 0, data);
// data[0] = MINION_RESULT_INT;
+#if ENABLE_INT_NONO
data[0] = MINION_RESULT_INT | MINION_CMD_INT;
+#else
+ data[0] = 0x00;
+#endif
data[1] = 0x00;
data[2] = 0x00;
data[3] = 0x00;
@@ -1384,7 +1320,8 @@ static void minion_detect_chips(struct cgpu_info *minioncgpu, struct minion_info
minioncgpu->drv->dname, chip, sig,
MINION_CHIP_SIG);
} else {
- if (sig == MINION_NOCHIP_SIG) // Assume no chip
+ if (sig == MINION_NOCHIP_SIG ||
+ sig == MINION_NOCHIP_SIG2) // Assume no chip
ok = true;
else {
applog(LOG_ERR, "%s: chip %d detect failed got"
@@ -1492,6 +1429,7 @@ bad_out:
return false;
}
+#if ENABLE_INT_NONO
static bool minion_init_gpio_interrupt(struct cgpu_info *minioncgpu, struct minion_info *minioninfo)
{
char pindir[64], ena[64], pin[8], dir[64], edge[64], act[64];
@@ -1644,13 +1582,31 @@ static bool minion_init_gpio_interrupt(struct cgpu_info *minioncgpu, struct mini
return true;
}
+#endif
-static void minion_process_options(struct minion_info *minioninfo)
+// Default meaning all cores
+static void default_all_cores(uint8_t *cores)
{
- int last_freq = MINION_FREQ_DEF;
- char *freq, *comma, *buf;
int i;
+ // clear all bits
+ for (i = 0; i < (int)(DATA_SIZ * MINION_CORE_REPS); i++)
+ cores[i] = 0x00;
+
+ // enable (only) all cores
+ for (i = 0; i < MINION_CORES; i++)
+ ENABLE_CORE(cores, i);
+}
+
+static void minion_process_options(struct minion_info *minioninfo)
+{
+ int last_freq, last_temp;
+ char *freq, *temp, *core, *comma, *buf, *plus, *minus;
+ uint8_t last_cores[DATA_SIZ*MINION_CORE_REPS];
+ int i, core1, core2;
+ bool cleared;
+
+ last_freq = MINION_FREQ_DEF;
if (opt_minion_freq && *opt_minion_freq) {
buf = freq = strdup(opt_minion_freq);
comma = strchr(freq, ',');
@@ -1674,7 +1630,108 @@ static void minion_process_options(struct minion_info *minioninfo)
}
minioninfo->init_freq[i] = last_freq;
}
+ free(buf);
+ }
+
+ last_temp = MINION_TEMP_CTL_DEF;
+ if (opt_minion_temp && *opt_minion_temp) {
+ buf = temp = strdup(opt_minion_temp);
+ comma = strchr(temp, ',');
+ if (comma)
+ *(comma++) = '\0';
+ for (i = 0; i < MINION_CHIPS; i++) {
+ if (temp) {
+ if (isdigit(*temp)) {
+ last_temp = atoi(temp);
+ last_temp -= (last_temp % MINION_TEMP_CTL_STEP);
+ if (last_temp < MINION_TEMP_CTL_MIN_VALUE)
+ last_temp = MINION_TEMP_CTL_MIN_VALUE;
+ if (last_temp > MINION_TEMP_CTL_MAX_VALUE)
+ last_temp = MINION_TEMP_CTL_MAX_VALUE;
+ } else {
+ if (strcasecmp(temp, MINION_TEMP_DISABLE) == 0)
+ last_temp = MINION_TEMP_CTL_DISABLE;
+ }
+
+ temp = comma;
+ if (comma) {
+ comma = strchr(temp, ',');
+ if (comma)
+ *(comma++) = '\0';
+ }
+ }
+ minioninfo->init_temp[i] = last_temp;
+ }
+ free(buf);
+ }
+
+ default_all_cores(&(last_cores[0]));
+ // default to all cores until we find valid data
+ cleared = false;
+ if (opt_minion_cores && *opt_minion_cores) {
+ buf = core = strdup(opt_minion_cores);
+ comma = strchr(core, ',');
+ if (comma)
+ *(comma++) = '\0';
+
+ for (i = 0; i < MINION_CHIPS; i++) {
+ // default to previous until we find valid data
+ cleared = false;
+ if (core) {
+ plus = strchr(core, '+');
+ if (plus)
+ *(plus++) = '\0';
+ while (core) {
+ minus = strchr(core, '-');
+ if (minus)
+ *(minus++) = '\0';
+ if (isdigit(*core)) {
+ core1 = atoi(core);
+ if (core1 >= 0 && core1 < MINION_CORES) {
+ if (!minus) {
+ if (!cleared) {
+ memset(last_cores, 0, sizeof(last_cores));
+ cleared = true;
+ }
+ ENABLE_CORE(last_cores, core1);
+ } else {
+ core2 = atoi(minus);
+ if (core2 >= core1) {
+ if (core2 >= MINION_CORES)
+ core2 = MINION_CORES - 1;
+ while (core1 <= core2) {
+ if (!cleared) {
+ memset(last_cores, 0,
+ sizeof(last_cores));
+ cleared = true;
+ }
+ ENABLE_CORE(last_cores, core1);
+ core1++;
+ }
+ }
+ }
+ }
+ } else {
+ if (strcasecmp(core, MINION_CORE_ALL) == 0)
+ default_all_cores(&(last_cores[0]));
+ }
+ core = plus;
+ if (plus) {
+ plus = strchr(core, '+');
+ if (plus)
+ *(plus++) = '\0';
+ }
+ }
+ core = comma;
+ if (comma) {
+ comma = strchr(core, ',');
+ if (comma)
+ *(comma++) = '\0';
+ }
+ }
+ memcpy(&(minioninfo->init_cores[i][0]), &(last_cores[0]), sizeof(last_cores));
+ }
free(buf);
}
}
@@ -1683,6 +1740,8 @@ static void minion_detect(bool hotplug)
{
struct cgpu_info *minioncgpu = NULL;
struct minion_info *minioninfo = NULL;
+ char buf[512];
+ size_t off;
int i;
if (hotplug)
@@ -1704,14 +1763,20 @@ static void minion_detect(bool hotplug)
if (!minion_init_spi(minioncgpu, minioninfo, MINION_SPI_BUS, MINION_SPI_CHIP))
goto unalloc;
+#if ENABLE_INT_NONO
if (!minion_init_gpio_interrupt(minioncgpu, minioninfo))
goto unalloc;
+#endif
mutex_init(&(minioninfo->spi_lock));
mutex_init(&(minioninfo->sta_lock));
- for (i = 0; i < MINION_CHIPS; i++)
+ for (i = 0; i < MINION_CHIPS; i++) {
minioninfo->init_freq[i] = MINION_FREQ_DEF;
+ minioninfo->init_temp[i] = MINION_TEMP_CTL_DEF;
+ default_all_cores(&(minioninfo->init_cores[i][0]));
+ }
+
minion_process_options(minioninfo);
@@ -1719,9 +1784,17 @@ static void minion_detect(bool hotplug)
minion_detect_chips(minioncgpu, minioninfo);
- applog(LOG_WARNING, "%s: found %d chip%s",
+ buf[0] = '\0';
+ for (i = 0; i < MINION_CHIPS; i++) {
+ if (minioninfo->chip[i]) {
+ off = strlen(buf);
+ snprintf(buf + off, sizeof(buf) - off, " %d", i);
+ }
+ }
+
+ applog(LOG_WARNING, "%s: found %d chip%s:%s",
minioncgpu->drv->dname, minioninfo->chips,
- (minioninfo->chips == 1) ? "" : "s");
+ (minioninfo->chips == 1) ? "" : "s", buf);
if (minioninfo->chips == 0)
goto cleanup;
@@ -1731,18 +1804,25 @@ static void minion_detect(bool hotplug)
mutex_init(&(minioninfo->nonce_lock));
- minioninfo->wfree_list = new_list("Work", sizeof(WITEM), ALLOC_WITEMS, true, MINION_FFL_HERE);
- minioninfo->wwork_list = new_store(minioninfo->wfree_list);
+ minioninfo->wfree_list = k_new_list("Work", sizeof(WITEM), ALLOC_WITEMS, LIMIT_WITEMS, true);
+ minioninfo->wwork_list = k_new_store(minioninfo->wfree_list);
// Initialise them all in case we later decide to enable chips
- for (i = 0; i < MINION_CHIPS; i++)
- minioninfo->wchip_list[i] = new_store(minioninfo->wfree_list);
+ for (i = 0; i < MINION_CHIPS; i++) {
+ minioninfo->wque_list[i] = k_new_store(minioninfo->wfree_list);
+ minioninfo->wchip_list[i] = k_new_store(minioninfo->wfree_list);
+ }
+
+ minioninfo->tfree_list = k_new_list("Task", sizeof(TITEM), ALLOC_TITEMS, LIMIT_TITEMS, true);
+ minioninfo->task_list = k_new_store(minioninfo->tfree_list);
+ minioninfo->treply_list = k_new_store(minioninfo->tfree_list);
- minioninfo->tfree_list = new_list("Task", sizeof(TITEM), ALLOC_TITEMS, true, MINION_FFL_HERE);
- minioninfo->task_list = new_store(minioninfo->tfree_list);
- minioninfo->treply_list = new_store(minioninfo->tfree_list);
+ minioninfo->rfree_list = k_new_list("Reply", sizeof(RITEM), ALLOC_RITEMS, LIMIT_RITEMS, true);
+ minioninfo->rnonce_list = k_new_store(minioninfo->rfree_list);
- minioninfo->rfree_list = new_list("Reply", sizeof(RITEM), ALLOC_RITEMS, true, MINION_FFL_HERE);
- minioninfo->rnonce_list = new_store(minioninfo->rfree_list);
+ minioninfo->history_gen = MINION_MAX_RESET_CHECK;
+ minioninfo->hfree_list = k_new_list("History", sizeof(HITEM), ALLOC_HITEMS, LIMIT_HITEMS, true);
+ for (i = 0; i < MINION_CHIPS; i++)
+ minioninfo->hchip_list[i] = k_new_store(minioninfo->hfree_list);
cgsem_init(&(minioninfo->task_ready));
cgsem_init(&(minioninfo->nonce_ready));
@@ -1776,7 +1856,7 @@ static void *minion_spi_write(void *userdata)
{
struct cgpu_info *minioncgpu = (struct cgpu_info *)userdata;
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
- K_ITEM *item, *tail, *task;
+ K_ITEM *item, *tail, *task, *work;
TITEM *titem;
applog(MINION_LOG, "%s%i: SPI writing...",
@@ -1807,7 +1887,7 @@ static void *minion_spi_write(void *userdata)
if (!item)
item = tail;
- k_remove(minioninfo->task_list, item);
+ k_unlink_item(minioninfo->task_list, item);
}
K_WUNLOCK(minioninfo->task_list);
@@ -1818,19 +1898,24 @@ static void *minion_spi_write(void *userdata)
titem = DATAT(item);
switch (titem->address) {
- // TODO: case MINION_CORE_ENA0_31:
- // TODO: case MINION_CORE_ENA32_63:
- // TODO: case MINION_CORE_ENA64_95:
- // TODO: case MINION_CORE_ENA96_98:
// TODO: case MINION_SYS_TEMP_CTL:
// TODO: case MINION_SYS_FREQ_CTL:
case READ_ADDR(MINION_SYS_CHIP_STA):
+ case WRITE_ADDR(MINION_SYS_RSTN_CTL):
+ case WRITE_ADDR(MINION_SYS_INT_CLR):
+ case READ_ADDR(MINION_SYS_IDLE_CNT):
+ case READ_ADDR(MINION_CORE_ENA0_31):
+ case READ_ADDR(MINION_CORE_ENA32_63):
+ case READ_ADDR(MINION_CORE_ENA64_95):
+ case READ_ADDR(MINION_CORE_ENA96_98):
+ case READ_ADDR(MINION_CORE_ACT0_31):
+ case READ_ADDR(MINION_CORE_ACT32_63):
+ case READ_ADDR(MINION_CORE_ACT64_95):
+ case READ_ADDR(MINION_CORE_ACT96_98):
store_reply = false;
break;
case WRITE_ADDR(MINION_QUE_0):
- store_reply = false;
- break;
- case WRITE_ADDR(MINION_SYS_RSTN_CTL):
+//applog(LOG_ERR, "%s%i: ZZZ send task_id 0x%04x - chip %d", minioncgpu->drv->name, minioncgpu->device_id, titem->task_id, titem->chip);
store_reply = false;
break;
default:
@@ -1847,11 +1932,11 @@ static void *minion_spi_write(void *userdata)
if (do_txrx) {
minion_txrx(titem);
+ int chip = titem->chip;
switch (titem->address) {
case READ_ADDR(MINION_SYS_CHIP_STA):
if (titem->reply >= (int)(titem->osiz)) {
uint8_t *rep = &(titem->rbuf[titem->osiz - titem->rsiz]);
- int chip = titem->chip;
mutex_lock(&(minioninfo->sta_lock));
minioninfo->chip_status[chip].temp = STA_TEMP(rep);
@@ -1864,23 +1949,31 @@ static void *minion_spi_write(void *userdata)
case MINION_TEMP_40:
case MINION_TEMP_60:
case MINION_TEMP_80:
+ cgtime(&(minioninfo->chip_status[chip].lastrecover));
minioninfo->chip_status[chip].overheat = false;
applog(LOG_WARNING, "%s%d: chip %d cooled, restarting",
minioncgpu->drv->name,
minioncgpu->device_id,
chip);
+ cgtime(&(minioninfo->chip_status[chip].lastrecover));
+ minioninfo->chip_status[chip].overheattime +=
+ tdiff(&(minioninfo->chip_status[chip].lastrecover),
+ &(minioninfo->chip_status[chip].lastoverheat));
break;
default:
break;
}
} else {
- if (STA_TEMP(rep) == MINION_TEMP_OVER) {
+ if (opt_minion_overheat && STA_TEMP(rep) == MINION_TEMP_OVER) {
+ cgtime(&(minioninfo->chip_status[chip].lastoverheat));
+ minioninfo->chip_status[chip].overheat = true;
applog(LOG_WARNING, "%s%d: chip %d overheated! idling",
minioncgpu->drv->name,
minioncgpu->device_id,
chip);
K_WLOCK(minioninfo->tfree_list);
- task = k_get_head(minioninfo->tfree_list, MINION_FFL_HERE);
+ task = k_unlink_head(minioninfo->tfree_list);
+ DATAT(task)->tid = ++(minioninfo->next_tid);
DATAT(task)->chip = chip;
DATAT(task)->write = true;
DATAT(task)->address = MINION_SYS_RSTN_CTL;
@@ -1892,16 +1985,75 @@ static void *minion_spi_write(void *userdata)
DATAT(task)->wbuf[2] = 0;
DATAT(task)->wbuf[3] = 0;
DATAT(task)->urgent = true;
- k_add_head(minioninfo->task_list, task, MINION_FFL_HERE);
+ k_add_head(minioninfo->task_list, task);
K_WUNLOCK(minioninfo->tfree_list);
-
- minioninfo->chip_status[chip].overheat = true;
+ minioninfo->chip_status[chip].overheats++;
}
}
}
break;
- case WRITE_ADDR(MINION_QUE_0):
+ case READ_ADDR(MINION_SYS_IDLE_CNT):
+ {
+ uint32_t *cnt = (uint32_t *)&(titem->rbuf[titem->osiz - titem->rsiz]);
+ minioninfo->chip_status[chip].idle = *cnt;
+ }
+ break;
case WRITE_ADDR(MINION_SYS_RSTN_CTL):
+//applog(LOG_WARNING, "%s%d: RSTN on chip %d", minioncgpu->drv->name, minioncgpu->device_id, chip);
+ // Do this here after it has actually been flushed
+ if ((titem->wbuf[0] & SYS_RSTN_CTL_FLUSH) == SYS_RSTN_CTL_FLUSH) {
+//applog(LOG_WARNING, "%s%d: flushing chip %d", minioncgpu->drv->name, minioncgpu->device_id, chip);
+//int ii = 0;
+//uint32_t fw = 0, lw = 0;
+ K_WLOCK(minioninfo->wwork_list);
+ work = minioninfo->wchip_list[chip]->head;
+//if (work) fw = DATAW(work)->task_id;
+ while (work) {
+ DATAW(work)->stale = true;
+ minioninfo->chip_status[chip].chipwork--;
+ if (minioninfo->chip_status[chip].realwork > 0)
+ minioninfo->chip_status[chip].realwork--;
+//lw = DATAW(work)->task_id;
+ work = work->next;
+//ii++;
+ }
+ minioninfo->chip_status[chip].chipwork = 0;
+ minioninfo->chip_status[chip].realwork = 0;
+ K_WUNLOCK(minioninfo->wwork_list);
+//applog(LOG_WARNING, "%s%d: flushed chip %d ii %d from task %d=0x%x to %d=0x%x", minioncgpu->drv->name, minioncgpu->device_id, chip, ii, (int)fw, (int)fw, (int)lw, (int)lw);
+ }
+ break;
+ case WRITE_ADDR(MINION_QUE_0):
+ K_WLOCK(minioninfo->wchip_list[chip]);
+ k_unlink_item(minioninfo->wque_list[chip], titem->witem);
+ k_add_head(minioninfo->wchip_list[chip], titem->witem);
+ minioninfo->chip_status[chip].quework--;
+ minioninfo->chip_status[chip].chipwork++;
+ minioninfo->chip_status[chip].realwork++;
+ K_WUNLOCK(minioninfo->wchip_list[chip]);
+ break;
+ case READ_ADDR(MINION_CORE_ENA0_31):
+ case READ_ADDR(MINION_CORE_ENA32_63):
+ case READ_ADDR(MINION_CORE_ENA64_95):
+ case READ_ADDR(MINION_CORE_ENA96_98):
+ {
+ uint32_t *rep = (uint32_t *)&(titem->rbuf[titem->osiz - titem->rsiz]);
+ int off = titem->address - READ_ADDR(MINION_CORE_ENA0_31);
+ minioninfo->chip_core_ena[off][chip] = *rep;
+ }
+ break;
+ case READ_ADDR(MINION_CORE_ACT0_31):
+ case READ_ADDR(MINION_CORE_ACT32_63):
+ case READ_ADDR(MINION_CORE_ACT64_95):
+ case READ_ADDR(MINION_CORE_ACT96_98):
+ {
+ uint32_t *rep = (uint32_t *)&(titem->rbuf[titem->osiz - titem->rsiz]);
+ int off = titem->address - READ_ADDR(MINION_CORE_ACT0_31);
+ minioninfo->chip_core_act[off][chip] = *rep;
+ }
+ break;
+ case WRITE_ADDR(MINION_SYS_INT_CLR):
+ break;
default:
break;
}
@@ -1909,9 +2061,9 @@ static void *minion_spi_write(void *userdata)
K_WLOCK(minioninfo->treply_list);
if (store_reply)
- k_add_head(minioninfo->treply_list, item, MINION_FFL_HERE);
+ k_add_head(minioninfo->treply_list, item);
else
- k_free_head(minioninfo->tfree_list, item, MINION_FFL_HERE);
+ k_free_head(minioninfo->tfree_list, item);
K_WUNLOCK(minioninfo->treply_list);
/*
@@ -1933,17 +2085,24 @@ static void *minion_spi_reply(void *userdata)
{
struct cgpu_info *minioncgpu = (struct cgpu_info *)userdata;
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
- struct minion_result *result;
+ struct minion_result *result1, *result2, *use1, *use2;
K_ITEM *item;
- TITEM fifo_task, res_task;
- int chip, resoff, ret;
- struct pollfd pfd;
+ TITEM fifo_task, res1_task, res2_task;
+ int chip, resoff;
+ int chipwork, gap;
+ bool somelow;
+ struct timeval now;
+#if ENABLE_INT_NONO
+ TITEM clr_task;
+ struct pollfd pfd;
struct minion_header *head;
uint8_t rbuf[MINION_BUFSIZ];
uint8_t wbuf[MINION_BUFSIZ];
uint32_t wsiz, rsiz;
- int reply;
+ int ret, reply;
+ bool gotreplies = false;
+#endif
applog(MINION_LOG, "%s%i: SPI replying...",
minioncgpu->drv->name, minioncgpu->device_id);
@@ -1961,16 +2120,33 @@ static void *minion_spi_reply(void *userdata)
fifo_task.address = MINION_SYS_FIFO_STA;
fifo_task.wsiz = 0;
fifo_task.rsiz = MINION_SYS_SIZ;
- fifo_task.urgent = false;
- fifo_task.work = NULL;
- res_task.chip = 0;
- res_task.write = false;
- res_task.address = MINION_RES_DATA;
- res_task.wsiz = 0;
- res_task.rsiz = MINION_RES_DATA_SIZ;
- res_task.urgent = false;
- res_task.work = NULL;
+ res1_task.chip = 0;
+ res1_task.write = false;
+ if (minreread)
+ res1_task.address = MINION_RES_PEEK;
+ else
+ res1_task.address = MINION_RES_DATA;
+ res1_task.wsiz = 0;
+ res1_task.rsiz = MINION_RES_DATA_SIZ;
+
+ res2_task.chip = 0;
+ res2_task.write = false;
+ res2_task.address = MINION_RES_DATA;
+ res2_task.wsiz = 0;
+ res2_task.rsiz = MINION_RES_DATA_SIZ;
+
+#if ENABLE_INT_NONO
+ // Clear RESULT_INT after reading all results
+ clr_task.chip = 0;
+ clr_task.write = true;
+ clr_task.address = MINION_SYS_INT_CLR;
+ clr_task.wsiz = MINION_SYS_SIZ;
+ clr_task.rsiz = 0;
+ clr_task.wbuf[0] = MINION_RESULT_INT;
+ clr_task.wbuf[1] = 0;
+ clr_task.wbuf[2] = 0;
+ clr_task.wbuf[3] = 0;
memset(&pfd, 0, sizeof(pfd));
pfd.fd = minioninfo->gpiointfd;
@@ -1980,11 +2156,13 @@ static void *minion_spi_reply(void *userdata)
SET_HEAD_SIZ(head, MINION_SYS_SIZ);
wsiz = HSIZE() + MINION_SYS_SIZ;
rsiz = MINION_SYS_SIZ; // for READ, use 0 for WRITE
+#endif
+ somelow = false;
while (minioncgpu->shutdown == false) {
for (chip = 0; chip < MINION_CHIPS; chip++) {
if (minioninfo->chip[chip]) {
- uint8_t res = 0;
+ uint8_t res = 0, cmd = 0;
fifo_task.chip = chip;
fifo_task.reply = 0;
minion_txrx(&fifo_task);
@@ -2002,8 +2180,30 @@ static void *minion_spi_reply(void *userdata)
fifo_task.reply, (int)(fifo_task.osiz));
}
res = FIFO_RES(fifo_task.rbuf, fifo_task.osiz - fifo_task.rsiz);
+ cmd = FIFO_CMD(fifo_task.rbuf, fifo_task.osiz - fifo_task.rsiz);
}
}
+
+ K_WLOCK(minioninfo->wwork_list);
+ minioninfo->chip_status[chip].realwork = (uint32_t)cmd;
+ chipwork = (int)(minioninfo->chip_status[chip].chipwork);
+ K_WUNLOCK(minioninfo->wwork_list);
+ gap = chipwork - (int)cmd;
+ if (gap < -1 || gap > 1) {
+// applog(LOG_ERR, "%s%i: fifo cmd difference > 1 for chip %d - work %d cmd %d gap %d",
+// minioncgpu->drv->name, minioncgpu->device_id,
+// chip, chipwork, (int)cmd, gap);
+ }
+
+ if (cmd < MINION_QUE_LOW) {
+ somelow = true;
+ // Flag it in case the count is wrong
+ K_WLOCK(minioninfo->wwork_list);
+ minioninfo->chip_status[chip].islow = true;
+ minioninfo->chip_status[chip].lowcount = (int)cmd;
+ K_WUNLOCK(minioninfo->wwork_list);
+ }
+
/*
* Chip has results?
* You can't request results unless it says it has some.
@@ -2012,54 +2212,113 @@ static void *minion_spi_reply(void *userdata)
* i.e. there could be more, but never less
*/
uint8_t left = res;
+ if (res > MINION_MAX_RES) {
+ applog(LOG_ERR, "%s%i: Large work reply chip %d res %d",
+ minioncgpu->drv->name, minioncgpu->device_id, chip, res);
+ }
+//else
+//applog(LOG_ERR, "%s%i: work reply res %d", minioncgpu->drv->name, minioncgpu->device_id, res);
while (left > 0) {
res = left;
if (res > MINION_MAX_RES)
res = MINION_MAX_RES;
left -= res;
- res_task.chip = chip;
- res_task.reply = 0;
- res_task.rsiz = res * MINION_RES_DATA_SIZ;
- minion_txrx(&res_task);
- if (res_task.reply <= 0)
+ res1_task.chip = chip;
+ res1_task.reply = 0;
+ res1_task.rsiz = res * MINION_RES_DATA_SIZ;
+ minion_txrx(&res1_task);
+ if (res1_task.reply <= 0)
break;
else {
- if (res_task.reply < (int)MINION_RES_DATA_SIZ) {
- char *buf = bin2hex((unsigned char *)(&(res_task.rbuf[res_task.osiz - res_task.rsiz])), (int)(res_task.rsiz));
+ cgtime(&now);
+ if (res1_task.reply < (int)MINION_RES_DATA_SIZ) {
+ char *buf = bin2hex((unsigned char *)(&(res1_task.rbuf[res1_task.osiz - res1_task.rsiz])), (int)(res1_task.rsiz));
applog(LOG_ERR, "%s%i: Bad work reply (%s) size %d, should be at least %d",
minioncgpu->drv->name, minioncgpu->device_id, buf,
- res_task.reply, (int)MINION_RES_DATA_SIZ);
+ res1_task.reply, (int)MINION_RES_DATA_SIZ);
free(buf);
} else {
- if (res_task.reply != (int)(res_task.osiz)) {
+ if (res1_task.reply != (int)(res1_task.osiz)) {
applog(LOG_ERR, "%s%i: Unexpected work reply size %d, expected %d",
minioncgpu->drv->name, minioncgpu->device_id,
- res_task.reply, (int)(res_task.osiz));
+ res1_task.reply, (int)(res1_task.osiz));
}
- for (resoff = res_task.osiz - res_task.rsiz; resoff < (int)res_task.osiz; resoff += MINION_RES_DATA_SIZ) {
- result = (struct minion_result *)&(res_task.rbuf[resoff]);
- if (IS_RESULT(result)) {
+ if (minreread) {
+ res2_task.chip = chip;
+ res2_task.reply = 0;
+ res2_task.rsiz = res * MINION_RES_DATA_SIZ;
+ minion_txrx(&res2_task);
+ // Should never happen, but if it does, just wait for the next round
+ if (res2_task.reply <= 0)
+ break;
+ }
+
+ for (resoff = res1_task.osiz - res1_task.rsiz; resoff < (int)res1_task.osiz; resoff += MINION_RES_DATA_SIZ) {
+ result1 = (struct minion_result *)&(res1_task.rbuf[resoff]);
+ if (minreread && resoff < (int)res2_task.osiz)
+ result2 = (struct minion_result *)&(res2_task.rbuf[resoff]);
+ else
+ result2 = NULL;
+
+ if (IS_RESULT(result1) || (minreread && result2 && IS_RESULT(result2))) {
K_WLOCK(minioninfo->rfree_list);
- item = k_get_head(minioninfo->rfree_list, MINION_FFL_HERE);
+ item = k_unlink_head(minioninfo->rfree_list);
K_WUNLOCK(minioninfo->rfree_list);
- DATAR(item)->chip = RES_CHIP(result);
- DATAR(item)->core = RES_CORE(result);
- DATAR(item)->task_id = RES_TASK(result);
- DATAR(item)->nonce = RES_NONCE(result);
- DATAR(item)->no_nonce = !RES_GOLD(result);
-
-//if (RES_GOLD(result))
-//applog(LOG_ERR, "%s%i: found a result chip %d core %d task 0x%04x nonce 0x%08x", minioncgpu->drv->name, minioncgpu->device_id, DATAR(item)->chip, DATAR(item)->core, DATAR(item)->task_id, DATAR(item)->nonce);
+ if (IS_RESULT(result1)) {
+ use1 = result1;
+ if (minreread && result2 && IS_RESULT(result2))
+ use2 = result2;
+ else
+ use2 = NULL;
+ } else {
+ use1 = result2;
+ use2 = NULL;
+ }
+
+ //DATAR(item)->chip = RES_CHIP(use1);
+ // We can avoid any SPI transmission error of the chip number
+ DATAR(item)->chip = (uint8_t)chip;
+ if ((uint8_t)chip != RES_CHIP(use1)) {
+ minioninfo->spi_errors++;
+ minioninfo->chip_spi_errors[chip]++;
+ }
+ if (use2 && (uint8_t)chip != RES_CHIP(use2)) {
+ minioninfo->spi_errors++;
+ minioninfo->chip_spi_errors[chip]++;
+ }
+ DATAR(item)->core = RES_CORE(use1);
+ DATAR(item)->task_id = RES_TASK(use1);
+ DATAR(item)->nonce = RES_NONCE(use1);
+ DATAR(item)->no_nonce = !RES_GOLD(use1);
+ memcpy(&(DATAR(item)->when), &now, sizeof(now));
+ if (!use2)
+ DATAR(item)->another = false;
+ else {
+ DATAR(item)->another = true;
+ DATAR(item)->task_id2 = RES_TASK(use2);
+ DATAR(item)->nonce2 = RES_NONCE(use2);
+ }
+//applog(MINTASK_LOG, "%s%i: ZZZ reply task_id 0x%04x - chip %d - gold %d", minioncgpu->drv->name, minioncgpu->device_id, RES_TASK(use1), (int)RES_CHIP(use1), (int)RES_GOLD(use1));
+
+//if (RES_GOLD(use1))
+//applog(MINTASK_LOG, "%s%i: found a result chip %d core %d task 0x%04x nonce 0x%08x gold=%d", minioncgpu->drv->name, minioncgpu->device_id, DATAR(item)->chip, DATAR(item)->core, DATAR(item)->task_id, DATAR(item)->nonce, (int)RES_GOLD(use1));
K_WLOCK(minioninfo->rnonce_list);
- k_add_head(minioninfo->rnonce_list, item, MINION_FFL_HERE);
+ k_add_head(minioninfo->rnonce_list, item);
K_WUNLOCK(minioninfo->rnonce_list);
cgsem_post(&(minioninfo->nonce_ready));
} else {
- applog(LOG_ERR, "%s%i: Invalid task_id - chip %d",
- minioncgpu->drv->name, minioncgpu->device_id, chip);
+ minioninfo->res_err_count[chip]++;
+ applog(MINTASK_LOG, "%s%i: Invalid res0 task_id 0x%04x - chip %d",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ RES_TASK(result1), chip);
+ if (minreread && result2) {
+ applog(MINTASK_LOG, "%s%i: Invalid res1 task_id 0x%04x - chip %d",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ RES_TASK(result2), chip);
+ }
}
}
}
@@ -2068,6 +2327,17 @@ static void *minion_spi_reply(void *userdata)
}
}
+ if (somelow)
+ cgsem_post(&(minioninfo->scan_work));
+
+#if ENABLE_INT_NONO
+ if (gotreplies)
+ minion_txrx(&clr_task);
+#endif
+
+#if !ENABLE_INT_NONO
+ cgsleep_ms(MINION_REPLY_mS);
+#else
// TODO: this is going to require a bit of tuning with 2TH/s mining:
// The interrupt size MINION_RESULT_INT_SIZE should be high enough to expect
// most chips to have some results but low enough to cause negligible latency
@@ -2082,13 +2352,13 @@ static void *minion_spi_reply(void *userdata)
bool gotres;
int c;
+ minioninfo->interrupts++;
+
read(minioninfo->gpiointfd, &c, 1);
-/*
- applog(LOG_ERR, "%s%i: Interrupt",
- minioncgpu->drv->name,
- minioncgpu->device_id);
-*/
+// applog(LOG_ERR, "%s%i: Interrupt2",
+// minioncgpu->drv->name,
+// minioncgpu->device_id);
gotres = false;
for (chip = 0; chip < MINION_CHIPS; chip++) {
@@ -2103,54 +2373,43 @@ static void *minion_spi_reply(void *userdata)
chip, reply, (int)wsiz);
}
- if (rbuf[wsiz - rsiz] & MINION_RESULT_INT) {
+ snprintf(minioninfo->last_interrupt,
+ sizeof(minioninfo->last_interrupt),
+ "%d %d 0x%02x%02x%02x%02x%02x%02x%02x%02x %d %d 0x%02x %d %d",
+ (int)(minioninfo->interrupts), chip,
+ rbuf[0], rbuf[1], rbuf[2], rbuf[3],
+ rbuf[4], rbuf[5], rbuf[6], rbuf[7],
+ (int)wsiz, (int)rsiz, rbuf[wsiz - rsiz],
+ rbuf[wsiz - rsiz] & MINION_RESULT_INT,
+ rbuf[wsiz - rsiz] & MINION_CMD_INT);
+
+ if ((rbuf[wsiz - rsiz] & MINION_RESULT_INT) != 0) {
gotres = true;
-/*
- applog(LOG_ERR, "%s%i: chip %d got RES interrupt",
- minioncgpu->drv->name,
- minioncgpu->device_id,
- chip);
-*/
+ (minioninfo->result_interrupts)++;
+// applog(LOG_ERR, "%s%i: chip %d got RES interrupt",
+// minioncgpu->drv->name,
+// minioncgpu->device_id,
+// chip);
}
- if (rbuf[wsiz - rsiz] & MINION_CMD_INT) {
+ if ((rbuf[wsiz - rsiz] & MINION_CMD_INT) != 0) {
// Work queue is empty
-/*
- applog(LOG_ERR, "%s%i: chip %d got CMD interrupt",
- minioncgpu->drv->name,
- minioncgpu->device_id,
- chip);
-*/
- }
-
-/*
- {
- char *tmp;
- tmp = bin2hex(rbuf, wsiz);
- applog(LOG_ERR, "%s%i: chip %d interrupt: %s",
- minioncgpu->drv->name,
- minioncgpu->device_id,
- chip, tmp);
- free(tmp);
+ (minioninfo->command_interrupts)++;
+// applog(LOG_ERR, "%s%i: chip %d got CMD interrupt",
+// minioncgpu->drv->name,
+// minioncgpu->device_id,
+// chip);
}
-*/
- // TODO: try combining MINION_SYS_INT_STA and
- // MINION_SYS_INT_CLR in one ioctl()
+// char *tmp;
+// tmp = bin2hex(rbuf, wsiz);
+// applog(LOG_ERR, "%s%i: chip %d interrupt: %s",
+// minioncgpu->drv->name,
+// minioncgpu->device_id,
+// chip, tmp);
+// free(tmp);
- // Clear all the interrupt bits we got
- SET_HEAD_WRITE(head, MINION_SYS_INT_CLR);
- head->data[0] = rbuf[wsiz - rsiz];
- head->data[1] = 0x00;
- head->data[2] = 0x00;
- head->data[3] = 0x00;
- reply = do_ioctl(wbuf, wsiz, rbuf, 0);
- if (reply != (int)wsiz) {
- applog(LOG_ERR, "%s: chip %d int clear returned %d"
- " (should be %d)",
- minioncgpu->drv->dname,
- chip, reply, (int)wsiz);
- }
+ // Don't clear either interrupt until after send/recv
}
}
@@ -2158,6 +2417,7 @@ static void *minion_spi_reply(void *userdata)
if (gotres)
cgsem_post(&(minioninfo->scan_work));
}
+#endif
}
return NULL;
@@ -2173,22 +2433,38 @@ enum nonce_state {
NONCE_NO_NONCE,
NONCE_BAD_NONCE,
NONCE_BAD_WORK,
- NONCE_NO_WORK
+ NONCE_NO_WORK,
+ NONCE_SPI_ERR
};
static void cleanup_older(struct cgpu_info *minioncgpu, int chip, K_ITEM *item, bool no_nonce)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
K_ITEM *tail;
+// bool errs;
- // remove older work items (no_nonce means this 'item' has finished also)
+ /*
+ * remove older work items (no_nonce means this 'item' has finished also)
+ */
if (item->next || no_nonce) {
K_WLOCK(minioninfo->wchip_list[chip]);
tail = minioninfo->wchip_list[chip]->tail;
while (tail && tail != item) {
- k_remove(minioninfo->wchip_list[chip], tail);
- if (!(DATAW(tail)->stale))
- minioninfo->wchip_list[chip]->count_up--;
+ k_unlink_item(minioninfo->wchip_list[chip], tail);
+ if (!(DATAW(tail)->stale)) {
+ minioninfo->chip_status[chip].chipwork--;
+ if (minioninfo->chip_status[chip].realwork > 0)
+ minioninfo->chip_status[chip].realwork--;
+/*
+ // If it had no valid work (only errors) then it won't have been cleaned up
+ errs = (DATAW(tail)->errors > 0);
+ applog(errs ? LOG_DEBUG : LOG_ERR,
+ applog(LOG_ERR,
+ "%s%i: discarded old task 0x%04x chip %d no reply errs=%d",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ DATAW(tail)->task_id, chip, DATAW(tail)->errors);
+*/
+ }
K_WUNLOCK(minioninfo->wchip_list[chip]);
applog(MINION_LOG, "%s%i: marking complete - old task 0x%04x chip %d",
minioncgpu->drv->name, minioncgpu->device_id,
@@ -2198,15 +2474,18 @@ static void cleanup_older(struct cgpu_info *minioncgpu, int chip, K_ITEM *item,
else
work_completed(minioncgpu, DATAW(tail)->work);
K_WLOCK(minioninfo->wchip_list[chip]);
- k_free_head(minioninfo->wfree_list, tail, MINION_FFL_HERE);
+ k_free_head(minioninfo->wfree_list, tail);
tail = minioninfo->wchip_list[chip]->tail;
}
if (no_nonce) {
- k_remove(minioninfo->wchip_list[chip], item);
- if (!(DATAW(item)->stale))
- minioninfo->wchip_list[chip]->count_up--;
+ k_unlink_item(minioninfo->wchip_list[chip], item);
+ if (!(DATAW(item)->stale)) {
+ minioninfo->chip_status[chip].chipwork--;
+ if (minioninfo->chip_status[chip].realwork > 0)
+ minioninfo->chip_status[chip].realwork--;
+ }
K_WUNLOCK(minioninfo->wchip_list[chip]);
- applog(MINION_LOG, "%s%i: marking complete - old task 0x%04x chip %d",
+ applog(MINION_LOG, "%s%i: marking complete - no_nonce task 0x%04x chip %d",
minioncgpu->drv->name, minioncgpu->device_id,
DATAW(item)->task_id, chip);
if (DATAW(item)->rolled)
@@ -2214,47 +2493,95 @@ static void cleanup_older(struct cgpu_info *minioncgpu, int chip, K_ITEM *item,
else
work_completed(minioncgpu, DATAW(item)->work);
K_WLOCK(minioninfo->wchip_list[chip]);
- k_free_head(minioninfo->wfree_list, item, MINION_FFL_HERE);
+ k_free_head(minioninfo->wfree_list, item);
}
K_WUNLOCK(minioninfo->wchip_list[chip]);
}
}
-static enum nonce_state oknonce(struct thr_info *thr, struct cgpu_info *minioncgpu, int chip, int core, uint32_t task_id, uint32_t nonce, bool no_nonce)
+static enum nonce_state oknonce(struct thr_info *thr, struct cgpu_info *minioncgpu, int chip, int core,
+ uint32_t task_id, uint32_t nonce, bool no_nonce, struct timeval *when,
+ bool another, uint32_t task_id2, uint32_t nonce2)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
- K_ITEM *item;
+ struct timeval now;
+ K_ITEM *item, *tail;
+ uint32_t min_task_id, max_task_id;
+ bool redo;
+
+ // if the chip has been disabled - but we don't do that - so not possible (yet)
+ if (!(minioninfo->chip[chip])) {
+ applog(MINTASK_LOG, "%s%i: nonce error chip %d not present",
+ minioncgpu->drv->name, minioncgpu->device_id, chip);
+ return NONCE_NO_WORK;
+ }
- minioninfo->chip_nonces[chip]++;
+ if (core < 0 || core >= MINION_CORES) {
+ minioninfo->res_err_count[chip]++;
+ minioninfo->spi_errors++;
+ minioninfo->chip_spi_errors[chip]++;
+ applog(MINTASK_LOG, "%s%i: SPI nonce error invalid core %d (chip %d)",
+ minioncgpu->drv->name, minioncgpu->device_id, core, chip);
+ // use the fake core number so we don't discard the result
+ core = FAKE_CORE;
+ }
+
+ if (no_nonce)
+ minioninfo->chip_nononces[chip]++;
+ else
+ minioninfo->chip_nonces[chip]++;
+
+ redo = false;
+retry:
K_RLOCK(minioninfo->wchip_list[chip]);
item = minioninfo->wchip_list[chip]->tail;
if (!item) {
K_RUNLOCK(minioninfo->wchip_list[chip]);
- applog(LOG_ERR, "%s%i: no work (chip %d core %d task 0x%04x)",
- minioncgpu->drv->name, minioncgpu->device_id,
+ minioninfo->res_err_count[chip]++;
+ applog(MINTASK_LOG, "%s%i: chip %d has no tasks (core %d task 0x%04x)",
+ minioncgpu->drv->name, minioncgpu->device_id,
chip, core, (int)task_id);
- minioninfo->untested_nonces++;
+ if (!no_nonce) {
+ minioninfo->untested_nonces++;
+ minioninfo->chip_err[chip]++;
+ }
return NONCE_NO_WORK;
}
+ min_task_id = DATAW(item)->task_id;
while (item) {
if (DATAW(item)->task_id == task_id)
break;
item = item->prev;
}
+ max_task_id = DATAW(minioninfo->wchip_list[chip]->head)->task_id;
K_RUNLOCK(minioninfo->wchip_list[chip]);
if (!item) {
- applog(LOG_ERR, "%s%i: chip %d core %d unknown work task 0x%04x",
- minioncgpu->drv->name, minioncgpu->device_id,
- chip, core, (int)task_id);
- minioninfo->untested_nonces++;
+ if (another && task_id != task_id2) {
+ minioninfo->tasks_failed[chip]++;
+ task_id = task_id2;
+ redo = true;
+ goto retry;
+ }
+
+ minioninfo->res_err_count[chip]++;
+ applog(MINTASK_LOG, "%s%i: chip %d core %d unknown task 0x%04x (min=0x%04x max=0x%04x no_nonce=%d)",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ chip, core, (int)task_id, (int)min_task_id,
+ (int)max_task_id, no_nonce);
+ if (!no_nonce) {
+ minioninfo->untested_nonces++;
+ minioninfo->chip_err[chip]++;
+ }
return NONCE_BAD_WORK;
}
+ if (redo)
+ minioninfo->tasks_recovered[chip]++;
if (no_nonce) {
cleanup_older(minioncgpu, chip, item, no_nonce);
@@ -2263,10 +2590,15 @@ static enum nonce_state oknonce(struct thr_info *thr, struct cgpu_info *minioncg
minioninfo->tested_nonces++;
+ redo = false;
+retest:
if (test_nonce(DATAW(item)->work, nonce)) {
-//applog(LOG_ERR, "%s%i: Valid Nonce chip %d core %d task 0x%04x nonce 0x%08x", minioncgpu->drv->name, minioncgpu->device_id, chip, core, task_id, nonce);
+//applog(MINTASK_LOG, "%s%i: Valid Nonce chip %d core %d task 0x%04x nonce 0x%08x", minioncgpu->drv->name, minioncgpu->device_id, chip, core, task_id, nonce);
submit_tested_work(thr, DATAW(item)->work);
+ if (redo)
+ minioninfo->nonces_recovered[chip]++;
+
minioninfo->chip_good[chip]++;
minioninfo->core_good[chip][core]++;
DATAW(item)->nonces++;
@@ -2277,13 +2609,38 @@ static enum nonce_state oknonce(struct thr_info *thr, struct cgpu_info *minioncg
minioninfo->ok_nonces++;
cleanup_older(minioncgpu, chip, item, no_nonce);
+
+ int chip_tmp;
+ cgtime(&now);
+ K_WLOCK(minioninfo->hfree_list);
+ item = k_unlink_head(minioninfo->hfree_list);
+ memcpy(&(DATAH(item)->when), when, sizeof(*when));
+ k_add_head(minioninfo->hchip_list[chip], item);
+ for (chip_tmp = 0; chip_tmp < MINION_CHIPS; chip_tmp++) {
+ tail = minioninfo->hchip_list[chip_tmp]->tail;
+ while (tail && tdiff(&(DATAH(tail)->when), &now) > MINION_HISTORY_s) {
+ tail = k_unlink_tail(minioninfo->hchip_list[chip_tmp]);
+ k_add_head(minioninfo->hfree_list, item);
+ tail = minioninfo->hchip_list[chip_tmp]->tail;
+ }
+ }
+ K_WUNLOCK(minioninfo->hfree_list);
+
return NONCE_GOOD_NONCE;
}
+ if (another && nonce != nonce2) {
+ minioninfo->nonces_failed[chip]++;
+ nonce = nonce2;
+ redo = true;
+ goto retest;
+ }
+
+ DATAW(item)->errors++;
minioninfo->chip_bad[chip]++;
minioninfo->core_bad[chip][core]++;
inc_hw_errors(thr);
-//applog(LOG_ERR, "%s%i: HW ERROR chip %d core %d task 0x%04x nonce 0x%08x", minioncgpu->drv->name, minioncgpu->device_id, chip, core, task_id, nonce);
+//applog(MINTASK_LOG, "%s%i: HW ERROR chip %d core %d task 0x%04x nonce 0x%08x", minioncgpu->drv->name, minioncgpu->device_id, chip, core, task_id, nonce);
return NONCE_BAD_NONCE;
}
@@ -2298,6 +2655,10 @@ static void *minion_results(void *userdata)
uint32_t task_id;
uint32_t nonce;
bool no_nonce;
+ struct timeval when;
+ bool another;
+ uint32_t task_id2;
+ uint32_t nonce2;
applog(MINION_LOG, "%s%i: Results...",
minioncgpu->drv->name, minioncgpu->device_id);
@@ -2311,12 +2672,14 @@ static void *minion_results(void *userdata)
}
while (minioncgpu->shutdown == false) {
- if (!oldest_nonce(minioncgpu, &chip, &core, &task_id, &nonce, &no_nonce)) {
+ if (!oldest_nonce(minioncgpu, &chip, &core, &task_id, &nonce,
+ &no_nonce, &when, &another, &task_id2, &nonce2)) {
cgsem_mswait(&(minioninfo->nonce_ready), MINION_NONCE_mS);
continue;
}
- oknonce(thr, minioncgpu, chip, core, task_id, nonce, no_nonce);
+ oknonce(thr, minioncgpu, chip, core, task_id, nonce, no_nonce, &when,
+ another, task_id2, nonce2);
}
return NULL;
@@ -2325,26 +2688,15 @@ static void *minion_results(void *userdata)
static void minion_flush_work(struct cgpu_info *minioncgpu)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
- K_ITEM *stale_unused_work, *prev_unused, *task, *prev_task, *work;
+ K_ITEM *stale_unused_work, *prev_unused, *task, *prev_task, *witem;
int i;
applog(MINION_LOG, "%s%i: flushing work",
minioncgpu->drv->name, minioncgpu->device_id);
- // set stale all wchip_list contents
// TODO: N.B. scanwork also gets work locks - which master thread calls flush?
K_WLOCK(minioninfo->wwork_list);
- for (i = 0; i < MINION_CHIPS; i++)
- if (minioninfo->chip[i]) {
- work = minioninfo->wchip_list[i]->head;
- while (work) {
- DATAW(work)->stale = true;
- work = work->next;
- }
- minioninfo->wchip_list[i]->count_up = 0;
- }
-
// Simply remove the whole unused wwork_list
stale_unused_work = minioninfo->wwork_list->tail;
if (stale_unused_work) {
@@ -2368,18 +2720,20 @@ static void minion_flush_work(struct cgpu_info *minioncgpu)
while (task) {
prev_task = task->prev;
if (DATAT(task)->address == WRITE_ADDR(MINION_QUE_0)) {
- k_remove(minioninfo->task_list, task);
- /*
- * Discard it - the work is already in the wchip_list and
- * will be cleaned up by the next task on the chip
- */
- k_free_head(minioninfo->tfree_list, task, MINION_FFL_HERE);
+ minioninfo->chip_status[DATAT(task)->chip].quework--;
+ witem = DATAT(task)->witem;
+ k_unlink_item(minioninfo->wque_list[DATAT(task)->chip], witem);
+ k_free_head(minioninfo->wfree_list, witem);
+ k_unlink_item(minioninfo->task_list, task);
+ k_free_head(minioninfo->tfree_list, task);
}
task = prev_task;
}
for (i = 0; i < MINION_CHIPS; i++) {
if (minioninfo->chip[i]) {
- task = k_get_head(minioninfo->tfree_list, MINION_FFL_HERE);
+ // TODO: consider sending it now rather than adding to the task list?
+ task = k_unlink_head(minioninfo->tfree_list);
+ DATAT(task)->tid = ++(minioninfo->next_tid);
DATAT(task)->chip = i;
DATAT(task)->write = true;
DATAT(task)->address = MINION_SYS_RSTN_CTL;
@@ -2391,7 +2745,7 @@ static void minion_flush_work(struct cgpu_info *minioncgpu)
DATAT(task)->wbuf[2] = 0;
DATAT(task)->wbuf[3] = 0;
DATAT(task)->urgent = true;
- k_add_head(minioninfo->task_list, task, MINION_FFL_HERE);
+ k_add_head(minioninfo->task_list, task);
}
}
K_WUNLOCK(minioninfo->tfree_list);
@@ -2416,7 +2770,7 @@ static void minion_flush_work(struct cgpu_info *minioncgpu)
K_WLOCK(minioninfo->wfree_list);
while (stale_unused_work) {
prev_unused = stale_unused_work->prev;
- k_free_head(minioninfo->wfree_list, stale_unused_work, MINION_FFL_HERE);
+ k_free_head(minioninfo->wfree_list, stale_unused_work);
stale_unused_work = prev_unused;
}
K_WUNLOCK(minioninfo->wfree_list);
@@ -2428,7 +2782,7 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
struct timeval now;
K_ITEM *item;
- int limit;
+ int limit, rep;
cgtime(&now);
// No lock required since 'last' is only accessed here
@@ -2441,7 +2795,8 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
memcpy(&(minioninfo->chip_status[chip].last), &now, sizeof(now));
K_WLOCK(minioninfo->tfree_list);
- item = k_get_head(minioninfo->tfree_list, MINION_FFL_HERE);
+ item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->tfree_list);
DATAT(item)->chip = chip;
@@ -2453,10 +2808,58 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
DATAT(item)->urgent = false;
K_WLOCK(minioninfo->task_list);
- k_add_head(minioninfo->task_list, item, MINION_FFL_HERE);
+ k_add_head(minioninfo->task_list, item);
+ item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->task_list);
- cgtime(&(minioninfo->chip_status[chip].last));
+ DATAT(item)->chip = chip;
+ DATAT(item)->write = false;
+ DATAT(item)->address = READ_ADDR(MINION_SYS_IDLE_CNT);
+ DATAT(item)->task_id = 0;
+ DATAT(item)->wsiz = 0;
+ DATAT(item)->rsiz = MINION_SYS_SIZ;
+ DATAT(item)->urgent = false;
+
+ K_WLOCK(minioninfo->task_list);
+ k_add_head(minioninfo->task_list, item);
+ K_WUNLOCK(minioninfo->task_list);
+
+ // Get the core ena and act state
+ for (rep = 0; rep < MINION_CORE_REPS; rep++) {
+ // Ena
+ K_WLOCK(minioninfo->tfree_list);
+ item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
+ K_WUNLOCK(minioninfo->tfree_list);
+
+ DATAT(item)->chip = chip;
+ DATAT(item)->write = false;
+ DATAT(item)->address = READ_ADDR(MINION_CORE_ENA0_31 + rep);
+ DATAT(item)->task_id = 0;
+ DATAT(item)->wsiz = 0;
+ DATAT(item)->rsiz = MINION_SYS_SIZ;
+ DATAT(item)->urgent = false;
+
+ K_WLOCK(minioninfo->task_list);
+ k_add_head(minioninfo->task_list, item);
+ // Act
+ item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
+ K_WUNLOCK(minioninfo->task_list);
+
+ DATAT(item)->chip = chip;
+ DATAT(item)->write = false;
+ DATAT(item)->address = READ_ADDR(MINION_CORE_ACT0_31 + rep);
+ DATAT(item)->task_id = 0;
+ DATAT(item)->wsiz = 0;
+ DATAT(item)->rsiz = MINION_SYS_SIZ;
+ DATAT(item)->urgent = false;
+
+ K_WLOCK(minioninfo->task_list);
+ k_add_head(minioninfo->task_list, item);
+ K_WUNLOCK(minioninfo->task_list);
+ }
}
}
}
@@ -2468,7 +2871,8 @@ static void new_work_task(struct cgpu_info *minioncgpu, K_ITEM *witem, int chip,
K_ITEM *item;
K_WLOCK(minioninfo->tfree_list);
- item = k_get_head(minioninfo->tfree_list, MINION_FFL_HERE);
+ item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->tfree_list);
DATAT(item)->chip = chip;
@@ -2487,6 +2891,7 @@ static void new_work_task(struct cgpu_info *minioncgpu, K_ITEM *witem, int chip,
DATAT(item)->urgent = urgent;
DATAT(item)->work_state = state;
DATAT(item)->work = DATAW(witem)->work;
+ DATAT(item)->witem = witem;
que = (struct minion_que *)&(DATAT(item)->wbuf[0]);
que->task_id[0] = DATAT(item)->task_id & 0xff;
@@ -2498,8 +2903,13 @@ static void new_work_task(struct cgpu_info *minioncgpu, K_ITEM *witem, int chip,
DATAT(item)->wsiz = (int)sizeof(*que);
DATAT(item)->rsiz = 0;
+ K_WLOCK(minioninfo->wque_list[chip]);
+ k_add_head(minioninfo->wque_list[chip], witem);
+ minioninfo->chip_status[chip].quework++;
+ K_WUNLOCK(minioninfo->wque_list[chip]);
+
K_WLOCK(minioninfo->task_list);
- k_add_head(minioninfo->task_list, item, MINION_FFL_HERE);
+ k_add_head(minioninfo->task_list, item);
K_WUNLOCK(minioninfo->task_list);
if (urgent)
@@ -2516,9 +2926,7 @@ static K_ITEM *next_work(struct minion_info *minioninfo)
K_ITEM *item;
K_WLOCK(minioninfo->wwork_list);
- item = minioninfo->wwork_list->tail;
- if (item)
- k_remove(minioninfo->wwork_list, item);
+ item = k_unlink_tail(minioninfo->wwork_list);
K_WUNLOCK(minioninfo->wwork_list);
return item;
@@ -2527,9 +2935,13 @@ static K_ITEM *next_work(struct minion_info *minioninfo)
static void minion_do_work(struct cgpu_info *minioncgpu)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
- int count, chip, j;
+ int count, chip, j, lowcount;
uint8_t state;
K_ITEM *item;
+#if ENABLE_INT_NONO
+ K_ITEM *task;
+#endif
+ bool islow, sentwork;
// TODO: (remove this) Fake starved of work to test CMD Interrupt
// if (total_secs > 120) {
@@ -2539,26 +2951,35 @@ static void minion_do_work(struct cgpu_info *minioncgpu)
/*
* Fill the queues as follows:
- * 1) put at least 1 in each queue
- * 2) push each queue up to LOW
+ * 1) put at least 1 in each queue or if islow then add 1
+ * 2) push each queue up to LOW or if count is high but islow, then add LOW-1
* 3) push each LOW queue up to HIGH
*/
+
+ sentwork = false;
for (state = 0; state < 3; state++) {
+#define CHP 0
+//applog(LOG_ERR, "%s%i: chip %d presta %d: quew %d chw %d", minioncgpu->drv->name, minioncgpu->device_id, CHP, state, minioninfo->chip_status[CHP].quework, minioninfo->chip_status[CHP].chipwork);
+ for (chip = 0; chip < MINION_CHIPS; chip++)
+ minioninfo->chip_status[chip].tohigh = false;
+
for (chip = 0; chip < MINION_CHIPS; chip++) {
if (minioninfo->chip[chip] && !minioninfo->chip_status[chip].overheat) {
- K_RLOCK(minioninfo->wchip_list[chip]);
- count = minioninfo->wchip_list[chip]->count_up;
- K_RUNLOCK(minioninfo->wchip_list[chip]);
+ K_WLOCK(minioninfo->wchip_list[chip]);
+ count = minioninfo->chip_status[chip].quework +
+ minioninfo->chip_status[chip].realwork;
+ islow = minioninfo->chip_status[chip].islow;
+ minioninfo->chip_status[chip].islow = false;
+ lowcount = minioninfo->chip_status[chip].lowcount;
+ K_WUNLOCK(minioninfo->wchip_list[chip]);
switch (state) {
case 0:
- if (count == 0) {
+ if (count == 0 || islow) {
item = next_work(minioninfo);
if (item) {
new_work_task(minioncgpu, item, chip, true, state);
- K_WLOCK(minioninfo->wchip_list[chip]);
- k_add_head(minioninfo->wchip_list[chip], item, MINION_FFL_HERE);
- K_WUNLOCK(minioninfo->wchip_list[chip]);
+ sentwork = true;
applog(MINION_LOG, "%s%i: 0 task 0x%04x in chip %d list",
minioncgpu->drv->name,
minioncgpu->device_id,
@@ -2572,14 +2993,23 @@ static void minion_do_work(struct cgpu_info *minioncgpu)
}
break;
case 1:
- if (count < MINION_QUE_LOW) {
- for (j = count; j < MINION_QUE_LOW; j++) {
+ if (count < MINION_QUE_LOW || islow) {
+ // do case 2: after we've done other chips
+ minioninfo->chip_status[chip].tohigh = true;
+ j = count;
+ if (count >= MINION_QUE_LOW) {
+ // islow means run a full case 1
+ j = 1;
+ applog(LOG_ERR, "%s%i: chip %d low que (%d) with high count %d",
+ minioncgpu->drv->name,
+ minioncgpu->device_id,
+ chip, lowcount, count);
+ }
+ for (; j < MINION_QUE_LOW; j++) {
item = next_work(minioninfo);
if (item) {
new_work_task(minioncgpu, item, chip, false, state);
- K_WLOCK(minioninfo->wchip_list[chip]);
- k_add_head(minioninfo->wchip_list[chip], item, MINION_FFL_HERE);
- K_WUNLOCK(minioninfo->wchip_list[chip]);
+ sentwork = true;
applog(MINION_LOG, "%s%i: 1 task 0x%04x in chip %d list",
minioncgpu->drv->name,
minioncgpu->device_id,
@@ -2595,14 +3025,12 @@ static void minion_do_work(struct cgpu_info *minioncgpu)
}
break;
case 2:
- if (count <= MINION_QUE_LOW) {
+ if (count <= MINION_QUE_LOW || minioninfo->chip_status[chip].tohigh) {
for (j = count; j < MINION_QUE_HIGH; j++) {
item = next_work(minioninfo);
if (item) {
new_work_task(minioncgpu, item, chip, false, state);
- K_WLOCK(minioninfo->wchip_list[chip]);
- k_add_head(minioninfo->wchip_list[chip], item, MINION_FFL_HERE);
- K_WUNLOCK(minioninfo->wchip_list[chip]);
+ sentwork = true;
applog(MINION_LOG, "%s%i: 2 task 0x%04x in chip %d list",
minioncgpu->drv->name,
minioncgpu->device_id,
@@ -2623,6 +3051,31 @@ static void minion_do_work(struct cgpu_info *minioncgpu)
sys_chip_sta(minioncgpu, chip);
}
}
+
+ sentwork = sentwork;
+#if ENABLE_INT_NONO
+ if (sentwork) {
+ // Clear CMD interrupt since we've now sent more
+ K_WLOCK(minioninfo->tfree_list);
+ task = k_unlink_head(minioninfo->tfree_list);
+ DATAT(task)->tid = ++(minioninfo->next_tid);
+ DATAT(task)->chip = 0; // ignored
+ DATAT(task)->write = true;
+ DATAT(task)->address = MINION_SYS_INT_CLR;
+ DATAT(task)->task_id = 0; // ignored
+ DATAT(task)->wsiz = MINION_SYS_SIZ;
+ DATAT(task)->rsiz = 0;
+ DATAT(task)->wbuf[0] = MINION_CMD_INT;
+ DATAT(task)->wbuf[1] = 0;
+ DATAT(task)->wbuf[2] = 0;
+ DATAT(task)->wbuf[3] = 0;
+ DATAT(task)->urgent = false;
+ k_add_head(minioninfo->task_list, task);
+ K_WUNLOCK(minioninfo->tfree_list);
+ }
+#endif
+
+//applog(LOG_ERR, "%s%i: chip %d fin: quew %d chw %d", minioncgpu->drv->name, minioncgpu->device_id, CHP, minioninfo->chip_status[CHP].quework, minioninfo->chip_status[CHP].chipwork);
}
static bool minion_thread_prepare(struct thr_info *thr)
@@ -2725,6 +3178,131 @@ static bool minion_queue_full(struct cgpu_info *minioncgpu)
return ret;
}
+static void idle_report(struct cgpu_info *minioncgpu)
+{
+ struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
+ struct timeval now;
+ uint32_t idle;
+ int msdiff;
+ int chip;
+
+ for (chip = 0; chip < MINION_CHIPS; chip++) {
+ if (minioninfo->chip[chip]) {
+ idle = minioninfo->chip_status[chip].idle;
+ if (idle != minioninfo->chip_status[chip].last_rpt_idle) {
+ cgtime(&now);
+ msdiff = ms_tdiff(&now, &(minioninfo->chip_status[chip].idle_rpt));
+ if (msdiff >= MINION_IDLE_MESSAGE_ms) {
+ memcpy(&(minioninfo->chip_status[chip].idle_rpt), &now, sizeof(now));
+ applog(LOG_WARNING,
+ "%s%d: chip %d internal idle changed %08x",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ chip, idle);
+ minioninfo->chip_status[chip].last_rpt_idle = idle;
+ }
+ }
+ }
+ }
+}
+
+static void chip_report(struct cgpu_info *minioncgpu)
+{
+ struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
+ struct timeval now;
+ char buf[512];
+ char res_err_msg[2];
+ size_t len;
+ double ghs, expect, howlong;
+ int msdiff;
+ int chip;
+ int res_err_count;
+
+ cgtime(&now);
+ if (!(minioninfo->chip_chk.tv_sec)) {
+ memcpy(&(minioninfo->chip_chk), &now, sizeof(now));
+ memcpy(&(minioninfo->chip_rpt), &now, sizeof(now));
+ return;
+ }
+
+ if (opt_minion_chipreport > 0) {
+ msdiff = ms_tdiff(&now, &(minioninfo->chip_rpt));
+ if (msdiff >= (opt_minion_chipreport * 1000)) {
+ buf[0] = '\0';
+ res_err_msg[0] = '\0';
+ res_err_msg[1] = '\0';
+ K_RLOCK(minioninfo->hfree_list);
+ for (chip = 0; chip < MINION_CHIPS; chip++) {
+ if (minioninfo->chip[chip]) {
+ len = strlen(buf);
+ if (minioninfo->hchip_list[chip]->count < 2)
+ ghs = 0.0;
+ else {
+ ghs = 0xffffffffull * (minioninfo->hchip_list[chip]->count - 1);
+ ghs /= 1000000000.0;
+ ghs /= tdiff(&now, &(DATAH(minioninfo->hchip_list[chip]->tail)->when));
+ }
+ res_err_count = minioninfo->res_err_count[chip];
+ minioninfo->res_err_count[chip] = 0;
+ if (res_err_count > 100)
+ res_err_msg[0] = '!';
+ else if (res_err_count > 50)
+ res_err_msg[0] = '*';
+ else if (res_err_count > 0)
+ res_err_msg[0] = '\'';
+ else
+ res_err_msg[0] = '\0';
+ snprintf(buf + len, sizeof(buf) - len,
+ " %d=%s%.2f", chip, res_err_msg, ghs);
+ minioninfo->history_ghs[chip] = ghs;
+ }
+ }
+ K_RUNLOCK(minioninfo->hfree_list);
+ memcpy(&(minioninfo->chip_chk), &now, sizeof(now));
+ applogsiz(LOG_WARNING, 512,
+ "%s%d: Chip GHs%s",
+ minioncgpu->drv->name, minioncgpu->device_id, buf);
+ memcpy(&(minioninfo->chip_rpt), &now, sizeof(now));
+ }
+ }
+
+ msdiff = ms_tdiff(&now, &(minioninfo->chip_chk));
+ if (total_secs >= MINION_HISTORY_s && msdiff >= (minioninfo->history_gen * 1000)) {
+ K_RLOCK(minioninfo->hfree_list);
+ for (chip = 0; chip < MINION_CHIPS; chip++) {
+ if (minioninfo->chip[chip]) {
+ if (minioninfo->hchip_list[chip]->count < 2)
+ ghs = 0.0;
+ else {
+ ghs = 0xffffffffull * (minioninfo->hchip_list[chip]->count - 1);
+ ghs /= 1000000000.0;
+ ghs /= tdiff(&now, &(DATAH(minioninfo->hchip_list[chip]->tail)->when));
+ }
+ expect = (double)(minioninfo->init_freq[chip]) *
+ MINION_RESET_PERCENT / 1000.0;
+ howlong = tdiff(&now, &(minioninfo->last_reset[chip]));
+ if (ghs <= expect && howlong >= MINION_HISTORY_s)
+ minioninfo->do_reset[chip] = expect;
+ minioninfo->history_ghs[chip] = ghs;
+ }
+ }
+ K_RUNLOCK(minioninfo->hfree_list);
+
+ for (chip = 0; chip < MINION_CHIPS; chip++) {
+ if (minioninfo->chip[chip]) {
+ if (minioninfo->do_reset[chip] > 1.0) {
+ applog(LOG_WARNING, "%s%d: Chip %d down to threshold %.2fGHs - resetting ...",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ chip, minioninfo->do_reset[chip]);
+ minioninfo->do_reset[chip] = 0.0;
+ memcpy(&(minioninfo->last_reset[chip]), &now, sizeof(now));
+ init_chip(minioncgpu, minioninfo, chip);
+ }
+ }
+ }
+ memcpy(&(minioninfo->chip_chk), &now, sizeof(now));
+ }
+}
+
static int64_t minion_scanwork(__maybe_unused struct thr_info *thr)
{
struct cgpu_info *minioncgpu = thr->cgpu;
@@ -2740,6 +3318,12 @@ static int64_t minion_scanwork(__maybe_unused struct thr_info *thr)
}
mutex_unlock(&(minioninfo->nonce_lock));
+ if (opt_minion_idlecount)
+ idle_report(minioncgpu);
+
+ // Must always generate data to check/allow for chip reset
+ chip_report(minioncgpu);
+
/*
* To avoid wasting CPU, wait until we get an interrupt
* before returning back to the main cgminer work loop
@@ -2771,34 +3355,38 @@ static void minion_get_statline_before(char *buf, size_t bufsiz, struct cgpu_inf
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
uint16_t max_temp, cores;
- int chip;
+ int chip, core;
max_temp = 0;
cores = 0;
mutex_lock(&(minioninfo->sta_lock));
for (chip = 0; chip < MINION_CHIPS; chip++) {
if (minioninfo->chip[chip]) {
- cores += minioninfo->chip_status[chip].cores;
if (max_temp < minioninfo->chip_status[chip].temp)
max_temp = minioninfo->chip_status[chip].temp;
+ for (core = 0; core < MINION_CORES; core++) {
+ if (minioninfo->chip_core_ena[core >> 5][chip] & (0x1 << (core % 32)))
+ cores++;
+ }
}
}
mutex_unlock(&(minioninfo->sta_lock));
- tailsprintf(buf, bufsiz, "max%sC Ch:%2d Co:%d",
+ tailsprintf(buf, bufsiz, "max%sC Ch:%d Co:%d",
temp_str(max_temp), minioninfo->chips, (int)cores);
}
-#define CHIPS_PER_STAT 8
+#define CHIPS_PER_STAT 5
static struct api_data *minion_api_stats(struct cgpu_info *minioncgpu)
{
struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
struct api_data *root = NULL;
+ char cores[MINION_CORES+1];
char data[2048];
char buf[32];
int i, to, j;
- int chip, max_chip, chip_work;
+ int chip, max_chip, que_work, chip_work, temp;
if (minioninfo->initialised == false)
return NULL;
@@ -2823,10 +3411,69 @@ static struct api_data *minion_api_stats(struct cgpu_info *minioncgpu)
root = api_add_uint32(root, buf, &(minioninfo->chip_status[chip].freq), true);
snprintf(buf, sizeof(buf), "Chip %d InitFreq", chip);
root = api_add_int(root, buf, &(minioninfo->init_freq[chip]), true);
+ snprintf(buf, sizeof(buf), "Chip %d FreqSent", chip);
+ root = api_add_hex32(root, buf, &(minioninfo->chip_status[chip].freqsent), true);
+ snprintf(buf, sizeof(buf), "Chip %d InitTemp", chip);
+ temp = minioninfo->init_temp[chip];
+ if (temp == MINION_TEMP_CTL_DISABLE)
+ root = api_add_string(root, buf, MINION_TEMP_DISABLE, true);
+ else {
+ snprintf(data, sizeof(data), "%d", temp);
+ root = api_add_string(root, buf, data, true);
+ }
+ snprintf(buf, sizeof(buf), "Chip %d TempSent", chip);
+ root = api_add_hex32(root, buf, &(minioninfo->chip_status[chip].tempsent), true);
+ __bin2hex(data, (unsigned char *)(&(minioninfo->init_cores[chip][0])),
+ sizeof(minioninfo->init_cores[chip]));
+ snprintf(buf, sizeof(buf), "Chip %d InitCores", chip);
+ root = api_add_string(root, buf, data, true);
+ snprintf(buf, sizeof(buf), "Chip %d IdleCount", chip);
+ root = api_add_hex32(root, buf, &(minioninfo->chip_status[chip].idle), true);
+ snprintf(buf, sizeof(buf), "Chip %d QueWork", chip);
+ root = api_add_uint32(root, buf, &(minioninfo->chip_status[chip].quework), true);
+ snprintf(buf, sizeof(buf), "Chip %d ChipWork", chip);
+ root = api_add_uint32(root, buf, &(minioninfo->chip_status[chip].chipwork), true);
+ snprintf(buf, sizeof(buf), "Chip %d RealWork", chip);
+ root = api_add_uint32(root, buf, &(minioninfo->chip_status[chip].realwork), true);
+ snprintf(buf, sizeof(buf), "Chip %d QueListCount", chip);
+ root = api_add_int(root, buf, &(minioninfo->wque_list[chip]->count), true);
+ snprintf(buf, sizeof(buf), "Chip %d WorkListCount", chip);
+ root = api_add_int(root, buf, &(minioninfo->wchip_list[chip]->count), true);
snprintf(buf, sizeof(buf), "Chip %d Overheat", chip);
root = api_add_bool(root, buf, &(minioninfo->chip_status[chip].overheat), true);
+ snprintf(buf, sizeof(buf), "Chip %d Overheats", chip);
+ root = api_add_uint32(root, buf, &(minioninfo->chip_status[chip].overheats), true);
+ snprintf(buf, sizeof(buf), "Chip %d LastOverheat", chip);
+ root = api_add_timeval(root, buf, &(minioninfo->chip_status[chip].lastoverheat), true);
+ snprintf(buf, sizeof(buf), "Chip %d LastRecover", chip);
+ root = api_add_timeval(root, buf, &(minioninfo->chip_status[chip].lastrecover), true);
+ snprintf(buf, sizeof(buf), "Chip %d OverheatIdle", chip);
+ root = api_add_double(root, buf, &(minioninfo->chip_status[chip].overheattime), true);
+ for (i = 0; i < MINION_CORES; i++) {
+ if (minioninfo->chip_core_ena[i >> 5][chip] & (0x1 << (i % 32)))
+ cores[i] = 'o';
+ else
+ cores[i] = 'x';
+ }
+ cores[MINION_CORES] = '\0';
+ snprintf(buf, sizeof(buf), "Chip %d CoresEna", chip);
+ root = api_add_string(root, buf, cores, true);
+ for (i = 0; i < MINION_CORES; i++) {
+ if (minioninfo->chip_core_act[i >> 5][chip] & (0x1 << (i % 32)))
+ cores[i] = '-';
+ else
+ cores[i] = 'o';
+ }
+ cores[MINION_CORES] = '\0';
+ snprintf(buf, sizeof(buf), "Chip %d CoresAct", chip);
+ root = api_add_string(root, buf, cores, true);
+ snprintf(buf, sizeof(buf), "Chip %d History GHs", chip);
+ root = api_add_mhs(root, buf, &(minioninfo->history_ghs[chip]), true);
}
+ double his = MINION_HISTORY_s;
+ root = api_add_double(root, "History length", &his, true);
+
for (i = 0; i <= max_chip; i += CHIPS_PER_STAT) {
to = i + CHIPS_PER_STAT - 1;
if (to > max_chip)
@@ -2859,6 +3506,17 @@ static struct api_data *minion_api_stats(struct cgpu_info *minioncgpu)
snprintf(buf, sizeof(buf),
"%s%8"PRIu64,
j == i ? "" : " ",
+ minioninfo->chip_nononces[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "NoNonces %02d - %02d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%8"PRIu64,
+ j == i ? "" : " ",
minioninfo->chip_good[j]);
strcat(data, buf);
}
@@ -2875,16 +3533,55 @@ static struct api_data *minion_api_stats(struct cgpu_info *minioncgpu)
}
snprintf(buf, sizeof(buf), "Bad %02d - %02d", i, to);
root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%8"PRIu64,
+ j == i ? "" : " ",
+ minioninfo->chip_err[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Err %02d - %02d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%8"PRIu64,
+ j == i ? "" : " ",
+ minioninfo->chip_spi_errors[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "SpiErr %02d - %02d", i, to);
+ root = api_add_string(root, buf, data, true);
+
+ data[0] = '\0';
+ for (j = i; j <= to; j++) {
+ snprintf(buf, sizeof(buf),
+ "%s%"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64,
+ j == i ? "" : " ",
+ minioninfo->tasks_failed[j],
+ minioninfo->tasks_recovered[j],
+ minioninfo->nonces_failed[j],
+ minioninfo->nonces_recovered[j]);
+ strcat(data, buf);
+ }
+ snprintf(buf, sizeof(buf), "Redo %02d - %02d", i, to);
+ root = api_add_string(root, buf, data, true);
}
- chip_work = 0;
+ que_work = chip_work = 0;
for (chip = 0; chip <= max_chip; chip++)
- if (minioninfo->chip[chip])
+ if (minioninfo->chip[chip]) {
+ que_work += minioninfo->wchip_list[chip]->count;
chip_work += minioninfo->wchip_list[chip]->count;
+ }
root = api_add_int(root, "WFree Total", &(minioninfo->wfree_list->total), true);
root = api_add_int(root, "WFree Count", &(minioninfo->wfree_list->count), true);
root = api_add_int(root, "WWork Count", &(minioninfo->wwork_list->count), true);
+ root = api_add_int(root, "WQue Count", &que_work, true);
root = api_add_int(root, "WChip Count", &chip_work, true);
root = api_add_int(root, "TFree Total", &(minioninfo->tfree_list->total), true);
@@ -2942,8 +3639,14 @@ static struct api_data *minion_api_stats(struct cgpu_info *minioncgpu)
}
#endif
+ root = api_add_uint64(root, "SPI Errors", &(minioninfo->spi_errors), true);
root = api_add_uint64(root, "Work Unrolled", &(minioninfo->work_unrolled), true);
root = api_add_uint64(root, "Work Rolled", &(minioninfo->work_rolled), true);
+ root = api_add_uint64(root, "Ints", &(minioninfo->interrupts), true);
+ root = api_add_uint64(root, "Res Ints", &(minioninfo->result_interrupts), true);
+ root = api_add_uint64(root, "Cmd Ints", &(minioninfo->command_interrupts), true);
+ root = api_add_string(root, "Last Int", minioninfo->last_interrupt, true);
+ root = api_add_hex32(root, "Next TaskID", &(minioninfo->next_task_id), true);
root = api_add_elapsed(root, "Elapsed", &(total_secs), true);
diff --git a/miner.h b/miner.h
index ffa20ee..0de2381 100644
--- a/miner.h
+++ b/miner.h
@@ -1014,7 +1014,12 @@ extern char *opt_bitmain_options;
extern bool opt_bitmain_hwerror;
#endif
#ifdef USE_MINION
+extern int opt_minion_chipreport;
+extern char *opt_minion_cores;
extern char *opt_minion_freq;
+extern bool opt_minion_idlecount;
+extern bool opt_minion_overheat;
+extern char *opt_minion_temp;
#endif
#ifdef USE_USBUTILS
extern char *opt_usb_select;