- Timestamp:
- Sep 7, 2017 4:13:53 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r68625 r68701 459 459 }; 460 460 461 #ifdef IN_RING3 462 /** 463 * Acquires the HDA lock or returns. 464 */ 465 # define DEVHDA_LOCK(a_pThis) \ 461 /** 462 * Acquires the HDA lock. 463 */ 464 #define DEVHDA_LOCK(a_pThis) \ 466 465 do { \ 467 466 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 468 467 AssertRC(rcLock); \ 469 468 } while (0) 470 #endif 469 470 /** 471 * Acquires the HDA lock or returns. 472 */ 473 # define DEVHDA_LOCK_RETURN(a_pThis, a_rcBusy) \ 474 do { \ 475 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, a_rcBusy); \ 476 if (rcLock != VINF_SUCCESS) \ 477 { \ 478 AssertRC(rcLock); \ 479 return rcLock; \ 480 } \ 481 } while (0) 482 483 /** 484 * Acquires the HDA lock or returns. 485 */ 486 # define DEVHDA_LOCK_RETURN_VOID(a_pThis) \ 487 do { \ 488 int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 489 if (rcLock != VINF_SUCCESS) \ 490 { \ 491 AssertRC(rcLock); \ 492 return; \ 493 } \ 494 } while (0) 471 495 472 496 /** … … 479 503 * Acquires the TM lock and HDA lock, returns on failure. 480 504 */ 481 #define DEVHDA_LOCK_BOTH_RETURN(a_pThis, a_rcBusy) \ 505 #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pThis) \ 506 do { \ 507 int rcLock = TMTimerLock((a_pThis)->pTimer, VERR_IGNORED); \ 508 if (rcLock != VINF_SUCCESS) \ 509 { \ 510 AssertRC(rcLock); \ 511 return; \ 512 } \ 513 rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ 514 if (rcLock != VINF_SUCCESS) \ 515 { \ 516 AssertRC(rcLock); \ 517 TMTimerUnlock((a_pThis)->pTimer); \ 518 return; \ 519 } \ 520 } while (0) 521 522 /** 523 * Acquires the TM lock and HDA lock, returns on failure. 524 */ 525 #define DEVHDA_LOCK_BOTH_RETURN(a_pThis, a_rcBusy) \ 482 526 do { \ 483 527 int rcLock = TMTimerLock((a_pThis)->pTimer, (a_rcBusy)); \ … … 487 531 if (rcLock != VINF_SUCCESS) \ 488 532 { \ 533 AssertRC(rcLock); \ 489 534 TMTimerUnlock((a_pThis)->pTimer); \ 490 535 return rcLock; \ 491 536 } \ 492 537 } while (0) 493 494 538 495 539 /** … … 875 919 uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; 876 920 921 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); 922 877 923 *pu32Value = pThis->au32Regs[iRegMem] & g_aHdaRegMap[iReg].readable; 924 925 DEVHDA_UNLOCK(pThis); 878 926 return VINF_SUCCESS; 879 927 } … … 881 929 static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 882 930 { 931 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 932 883 933 uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; 884 934 885 935 pThis->au32Regs[iRegMem] = (u32Value & g_aHdaRegMap[iReg].writable) 886 936 | (pThis->au32Regs[iRegMem] & ~g_aHdaRegMap[iReg].writable); 937 DEVHDA_UNLOCK(pThis); 887 938 return VINF_SUCCESS; 888 939 } … … 894 945 if (u32Value & HDA_GCTL_CRST) 895 946 { 947 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 948 896 949 /* Set the CRST bit to indicate that we're leaving reset mode. */ 897 950 HDA_REG(pThis, GCTL) |= HDA_GCTL_CRST; 898 951 LogFunc(("Guest leaving HDA reset\n")); 952 953 DEVHDA_UNLOCK(pThis); 899 954 } 900 955 else 901 956 { 902 957 #ifdef IN_RING3 958 DEVHDA_LOCK(pThis); 959 903 960 /* Enter reset state. */ 904 961 LogFunc(("Guest entering HDA reset with DMA(RIRB:%s, CORB:%s)\n", … … 910 967 911 968 hdaGCTLReset(pThis); 969 970 DEVHDA_UNLOCK(pThis); 912 971 #else 913 972 return VINF_IOM_R3_MMIO_WRITE; … … 917 976 if (u32Value & HDA_GCTL_FCNTRL) 918 977 { 978 DEVHDA_LOCK(pThis); 979 919 980 /* Flush: GSTS:1 set, see 6.2.6. */ 920 981 HDA_REG(pThis, GSTS) |= HDA_GSTS_FSTS; /* Set the flush status. */ 921 982 /* DPLBASE and DPUBASE should be initialized with initial value (see 6.2.6). */ 922 } 983 984 DEVHDA_UNLOCK(pThis); 985 } 986 923 987 return VINF_SUCCESS; 924 988 } … … 926 990 static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) 927 991 { 992 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 993 928 994 uint32_t v = HDA_REG_IND(pThis, iReg); 929 995 uint32_t nv = u32Value & HDA_STATESTS_SCSF_MASK; … … 931 997 HDA_REG(pThis, STATESTS) &= ~(v & nv); /* Write of 1 clears corresponding bit. */ 932 998 999 DEVHDA_UNLOCK(pThis); 1000 933 1001 return VINF_SUCCESS; 934 1002 } … … 936 1004 static int hdaRegReadLPIB(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 937 1005 { 1006 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); 1007 938 1008 const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, LPIB, iReg); 939 1009 uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, uSD); … … 944 1014 945 1015 *pu32Value = u32LPIB; 1016 1017 DEVHDA_UNLOCK(pThis); 946 1018 return VINF_SUCCESS; 947 1019 } … … 990 1062 RT_NOREF(iReg); 991 1063 1064 DEVHDA_LOCK(pThis); 1065 992 1066 *pu32Value = RT_LO_U32(ASMAtomicReadU64(&pThis->u64WalClk)); 993 1067 994 1068 Log3Func(("%RU32 (max @ %RU64)\n",*pu32Value, hdaWalClkGetMax(pThis))); 995 1069 1070 DEVHDA_UNLOCK(pThis); 996 1071 return VINF_SUCCESS; 997 1072 #else … … 1005 1080 RT_NOREF_PV(iReg); 1006 1081 1082 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1083 1007 1084 if (u32Value & HDA_CORBRP_RST) 1008 1085 HDA_REG(pThis, CORBRP) = HDA_CORBRP_RST; /* Clears the pointer. */ … … 1010 1087 HDA_REG(pThis, CORBRP) &= ~HDA_CORBRP_RST; /* Only CORBRP_RST bit is writable. */ 1011 1088 1089 DEVHDA_UNLOCK(pThis); 1012 1090 return VINF_SUCCESS; 1013 1091 } … … 1018 1096 int rc = hdaRegWriteU8(pThis, iReg, u32Value); 1019 1097 AssertRC(rc); 1098 1099 DEVHDA_LOCK(pThis); 1100 1020 1101 if ( (uint8_t)HDA_REG(pThis, CORBWP) != (uint8_t)HDA_REG(pThis, CORBRP) 1021 1102 && (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA)) 1022 1103 { 1023 return hdaCORBCmdProcess(pThis); 1024 } 1104 rc = hdaCORBCmdProcess(pThis); 1105 } 1106 1107 DEVHDA_UNLOCK(pThis); 1108 1025 1109 return rc; 1026 1110 #else … … 1034 1118 RT_NOREF_PV(iReg); 1035 1119 1120 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1121 1036 1122 uint32_t v = HDA_REG(pThis, CORBSTS); 1037 1123 HDA_REG(pThis, CORBSTS) &= ~(v & u32Value); 1124 1125 DEVHDA_UNLOCK(pThis); 1126 1038 1127 return VINF_SUCCESS; 1039 1128 } … … 1042 1131 { 1043 1132 #ifdef IN_RING3 1044 int rc; 1045 rc = hdaRegWriteU16(pThis, iReg, u32Value); 1046 if (RT_FAILURE(rc)) 1047 AssertRCReturn(rc, rc); 1133 int rc = hdaRegWriteU16(pThis, iReg, u32Value); 1134 AssertRCReturn(rc, rc); 1135 1136 DEVHDA_LOCK(pThis); 1137 1048 1138 if ((uint8_t)HDA_REG(pThis, CORBWP) == (uint8_t)HDA_REG(pThis, CORBRP)) 1139 { 1140 DEVHDA_UNLOCK(pThis); 1049 1141 return VINF_SUCCESS; 1142 } 1143 1050 1144 if (!(HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA)) 1145 { 1146 DEVHDA_UNLOCK(pThis); 1051 1147 return VINF_SUCCESS; 1148 } 1149 1052 1150 rc = hdaCORBCmdProcess(pThis); 1151 1152 DEVHDA_UNLOCK(pThis); 1153 1053 1154 return rc; 1054 1155 #else /* !IN_RING3 */ … … 1061 1162 { 1062 1163 #ifdef IN_RING3 1164 DEVHDA_LOCK(pThis); 1165 1063 1166 PHDASTREAM pStream = hdaGetStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, CBL, iReg)); 1064 1167 if (!pStream) … … 1066 1169 LogFunc(("[SD%RU8] Warning: Changing SDCBL on non-attached stream (0x%x)\n", 1067 1170 HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value)); 1171 1172 DEVHDA_UNLOCK(pThis); 1068 1173 return hdaRegWriteU32(pThis, iReg, u32Value); 1069 1174 } 1070 1175 1071 1176 pStream->u32CBL = u32Value; 1177 1178 LogFlowFunc(("[SD%RU8] CBL=%RU32\n", pStream->u8SD, u32Value)); 1179 1180 DEVHDA_UNLOCK(pThis); 1072 1181 1073 1182 int rc2 = hdaRegWriteU32(pThis, iReg, u32Value); 1074 1183 AssertRC(rc2); 1075 1076 LogFlowFunc(("[SD%RU8] CBL=%RU32\n", pStream->u8SD, u32Value));1077 1184 1078 1185 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ … … 1086 1193 { 1087 1194 #ifdef IN_RING3 1195 DEVHDA_LOCK_BOTH_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1196 1088 1197 /* 1089 1198 * Some guests write too much (that is, 32-bit with the top 8 bit being junk) … … 1115 1224 { 1116 1225 LogFunc(("[SD%RU8] Warning: Invalid stream tag %RU8 specified!\n", uSD, uTag)); 1226 1227 DEVHDA_UNLOCK_BOTH(pThis); 1117 1228 return hdaRegWriteU24(pThis, iReg, u32Value); 1118 1229 } … … 1221 1332 } 1222 1333 1334 DEVHDA_UNLOCK_BOTH(pThis); 1335 1223 1336 int rc2 = hdaRegWriteU24(pThis, iReg, u32Value); 1224 1337 AssertRC(rc2); … … 1234 1347 { 1235 1348 #ifdef IN_RING3 1349 DEVHDA_LOCK(pThis); 1350 1236 1351 PHDASTREAM pStream = hdaGetStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, STS, iReg)); 1237 1352 if (!pStream) … … 1239 1354 AssertMsgFailed(("[SD%RU8] Warning: Writing SDSTS on non-attached stream (0x%x)\n", 1240 1355 HDA_SD_NUM_FROM_REG(pThis, STS, iReg), u32Value)); 1356 1357 DEVHDA_UNLOCK(pThis); 1241 1358 return hdaRegWriteU16(pThis, iReg, u32Value); 1242 1359 } … … 1281 1398 } 1282 1399 1400 DEVHDA_UNLOCK(pThis); 1283 1401 return VINF_SUCCESS; 1284 1402 #else /* IN_RING3 */ … … 1291 1409 { 1292 1410 #ifdef IN_RING3 1411 DEVHDA_LOCK(pThis); 1412 1293 1413 if (HDA_REG_IND(pThis, iReg) == u32Value) /* Value already set? */ 1414 { 1415 DEVHDA_UNLOCK(pThis); 1294 1416 return VINF_SUCCESS; 1417 } 1295 1418 1296 1419 uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, LVI, iReg); … … 1300 1423 { 1301 1424 AssertMsgFailed(("[SD%RU8] Warning: Changing SDLVI on non-attached stream (0x%x)\n", uSD, u32Value)); 1425 1426 DEVHDA_UNLOCK(pThis); 1302 1427 return hdaRegWriteU16(pThis, iReg, u32Value); 1303 1428 } … … 1316 1441 } 1317 1442 # endif 1443 1444 DEVHDA_UNLOCK(pThis); 1318 1445 1319 1446 int rc2 = hdaRegWriteU16(pThis, iReg, u32Value); … … 1330 1457 { 1331 1458 #ifdef IN_RING3 1459 DEVHDA_LOCK(pThis); 1460 1332 1461 uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOW, iReg); 1333 1462 … … 1335 1464 { 1336 1465 LogRel(("HDA: Warning: Guest tried to write read-only FIFOW to output stream #%RU8, ignoring\n", uSD)); 1466 1467 DEVHDA_UNLOCK(pThis); 1337 1468 return VINF_SUCCESS; 1338 1469 } … … 1342 1473 { 1343 1474 AssertMsgFailed(("[SD%RU8] Warning: Changing FIFOW on non-attached stream (0x%x)\n", uSD, u32Value)); 1475 1476 DEVHDA_UNLOCK(pThis); 1344 1477 return hdaRegWriteU16(pThis, iReg, u32Value); 1345 1478 } … … 1367 1500 LogFunc(("[SD%RU8] Updating FIFOW to %RU32 bytes\n", uSD, pStream->u16FIFOW)); 1368 1501 1502 DEVHDA_UNLOCK(pThis); 1503 1369 1504 int rc2 = hdaRegWriteU16(pThis, iReg, u32FIFOW); 1370 1505 AssertRC(rc2); 1371 1506 } 1372 1507 1508 DEVHDA_UNLOCK(pThis); 1373 1509 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 1374 1510 #else /* !IN_RING3 */ … … 1384 1520 { 1385 1521 #ifdef IN_RING3 1522 DEVHDA_LOCK(pThis); 1523 1386 1524 uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOS, iReg); 1387 1525 … … 1389 1527 { 1390 1528 LogRel(("HDA: Warning: Guest tried to write read-only FIFOS to input stream #%RU8, ignoring\n", uSD)); 1529 1530 DEVHDA_UNLOCK(pThis); 1391 1531 return VINF_SUCCESS; 1392 1532 } … … 1396 1536 { 1397 1537 AssertMsgFailed(("[SD%RU8] Warning: Changing FIFOS on non-attached stream (0x%x)\n", uSD, u32Value)); 1538 1539 DEVHDA_UNLOCK(pThis); 1398 1540 return hdaRegWriteU16(pThis, iReg, u32Value); 1399 1541 } … … 1425 1567 LogFunc(("[SD%RU8] Updating FIFOS to %RU32 bytes\n", uSD, pStream->u16FIFOS)); 1426 1568 1569 DEVHDA_UNLOCK(pThis); 1570 1427 1571 int rc2 = hdaRegWriteU16(pThis, iReg, u32FIFOS); 1428 1572 AssertRC(rc2); 1429 1573 } 1574 else 1575 DEVHDA_UNLOCK(pThis); 1430 1576 1431 1577 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ … … 1676 1822 { 1677 1823 #ifdef IN_RING3 1824 DEVHDA_LOCK(pThis); 1825 1678 1826 PHDASTREAM pStream = hdaGetStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, FMT, iReg)); 1679 1827 if (!pStream) … … 1704 1852 # endif 1705 1853 } 1854 1855 DEVHDA_UNLOCK(pThis); 1706 1856 return VINF_SUCCESS; /* Never return failure. */ 1707 1857 #else /* !IN_RING3 */ … … 1718 1868 AssertRC(rc2); 1719 1869 1870 DEVHDA_LOCK(pThis); 1871 1720 1872 PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); 1721 1873 if (!pStream) 1874 { 1875 DEVHDA_UNLOCK(pThis); 1722 1876 return VINF_SUCCESS; 1877 } 1723 1878 1724 1879 /* Update BDL base. */ … … 1737 1892 1738 1893 LogFlowFunc(("[SD%RU8] BDLBase=0x%x\n", pStream->u8SD, pStream->u64BDLBase)); 1894 1895 DEVHDA_UNLOCK(pThis); 1739 1896 1740 1897 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ … … 1757 1914 static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) 1758 1915 { 1916 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); 1917 1759 1918 /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */ 1760 1919 if ( HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP) … … 1764 1923 } 1765 1924 1925 DEVHDA_UNLOCK(pThis); 1926 1766 1927 return hdaRegReadU32(pThis, iReg, pu32Value); 1767 1928 } … … 1770 1931 { 1771 1932 RT_NOREF_PV(iReg); 1933 1934 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1772 1935 1773 1936 /* … … 1783 1946 if (HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP)) 1784 1947 { 1948 DEVHDA_UNLOCK(pThis); 1949 1785 1950 /* 1786 1951 * 3.4.3: Defines behavior of immediate Command status register. … … 1802 1967 /** @todo r=michaln We just set the IRS value, why are we clearing unset bits? */ 1803 1968 HDA_REG(pThis, IRS) &= ~HDA_IRS_ICB; /* busy is clear */ 1969 1970 DEVHDA_UNLOCK(pThis); 1804 1971 return VINF_SUCCESS; 1805 1972 #else /* !IN_RING3 */ 1973 DEVHDA_UNLOCK(pThis); 1806 1974 return VINF_IOM_R3_MMIO_WRITE; 1807 1975 #endif /* !IN_RING3 */ … … 1812 1980 */ 1813 1981 HDA_REG(pThis, IRS) &= ~(u32Value & HDA_IRS_IRV); 1982 1983 DEVHDA_UNLOCK(pThis); 1814 1984 return VINF_SUCCESS; 1815 1985 } … … 1818 1988 { 1819 1989 RT_NOREF_PV(iReg); 1990 1991 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1820 1992 1821 1993 if (u32Value & HDA_RIRBWP_RST) 1822 1994 HDA_REG(pThis, RIRBWP) = 0; 1995 1996 DEVHDA_UNLOCK(pThis); 1823 1997 1824 1998 /* The remaining bits are O, see 6.2.22. */ … … 1832 2006 if (RT_FAILURE(rc)) 1833 2007 AssertRCReturn(rc, rc); 2008 2009 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1834 2010 1835 2011 switch(iReg) … … 1871 2047 LogFunc(("CORB base:%llx RIRB base: %llx DP base: %llx\n", 1872 2048 pThis->u64CORBBase, pThis->u64RIRBBase, pThis->u64DPBase)); 2049 2050 DEVHDA_UNLOCK(pThis); 1873 2051 return rc; 1874 2052 } … … 1877 2055 { 1878 2056 RT_NOREF_PV(iReg); 2057 2058 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 1879 2059 1880 2060 uint8_t v = HDA_REG(pThis, RIRBSTS); 1881 2061 HDA_REG(pThis, RIRBSTS) &= ~(v & u32Value); 2062 2063 DEVHDA_UNLOCK(pThis); 1882 2064 1883 2065 #ifndef DEBUG … … 2307 2489 #ifndef VBOX_WITH_AUDIO_HDA_CALLBACKS 2308 2490 /** 2491 * Starts the internal audio device timer. 2492 * 2493 * @param pThis HDA state. 2494 */ 2495 static int hdaTimerStart(PHDASTATE pThis) 2496 { 2497 LogFlowFuncEnter(); 2498 2499 DEVHDA_LOCK_BOTH_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 2500 2501 AssertPtr(pThis->pTimer); 2502 2503 if (!pThis->fTimerActive) 2504 { 2505 LogRel2(("HDA: Starting transfers\n")); 2506 2507 pThis->fTimerActive = true; 2508 pThis->tsTimerExpire = TMTimerGet(pThis->pTimer) + pThis->cTimerTicks; /* Update current time timestamp. */ 2509 2510 /* Start transfers. */ 2511 hdaTimerMain(pThis); 2512 } 2513 2514 DEVHDA_UNLOCK_BOTH(pThis); 2515 2516 return VINF_SUCCESS; 2517 } 2518 2519 /** 2309 2520 * Starts the internal audio device timer (if not started yet). 2310 2521 * … … 2322 2533 /* Only start the timer at the first active stream. */ 2323 2534 if (pThis->cStreamsActive == 1) 2324 { 2325 LogRel2(("HDA: Starting transfers\n")); 2326 2327 /* Set timer flag. */ 2328 ASMAtomicXchgBool(&pThis->fTimerActive, true); 2329 2330 DEVHDA_LOCK_BOTH_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 2331 2332 /* Update current time timestamp. */ 2333 pThis->tsTimerExpire = TMTimerGet(pThis->pTimer) + pThis->cTimerTicks; 2334 2335 /* Start transfers. */ 2336 hdaTimerMain(pThis); 2337 2338 DEVHDA_UNLOCK_BOTH(pThis); 2339 } 2535 return hdaTimerStart(pThis); 2340 2536 2341 2537 return VINF_SUCCESS; … … 2351 2547 LogFlowFuncEnter(); 2352 2548 2353 if (! ASMAtomicReadBool(&pThis->fTimerActive))2549 if (!pThis->pTimer) /* Only can happen on device construction time, so no locking needed here. */ 2354 2550 return VINF_SUCCESS; 2355 2551 2356 LogRel2(("HDA: Stopping transfers ...\n")); 2357 2358 /* Set timer flag. */ 2359 ASMAtomicXchgBool(&pThis->fTimerActive, false); 2360 2361 if (pThis->pTimer) 2362 { 2363 DEVHDA_LOCK_BOTH_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 2552 DEVHDA_LOCK_BOTH_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 2553 2554 if (pThis->fTimerActive) 2555 { 2556 LogRel2(("HDA: Stopping transfers ...\n")); 2557 2558 pThis->fTimerActive = false; 2364 2559 2365 2560 TMTimerStop(pThis->pTimer); 2366 2367 DEVHDA_UNLOCK_BOTH(pThis); 2368 }2561 } 2562 2563 DEVHDA_UNLOCK_BOTH(pThis); 2369 2564 2370 2565 return VINF_SUCCESS; … … 2408 2603 STAM_PROFILE_START(&pThis->StatTimer, a); 2409 2604 2410 DEVHDA_LOCK (pThis);2605 DEVHDA_LOCK_BOTH_RETURN_VOID(pThis); 2411 2606 2412 2607 /* Flag indicating whether to kick the timer again for a … … 2442 2637 LogRel2(("HDA: Stopped transfers\n")); 2443 2638 2444 DEVHDA_UNLOCK (pThis);2639 DEVHDA_UNLOCK_BOTH(pThis); 2445 2640 2446 2641 STAM_PROFILE_STOP(&pThis->StatTimer, a); … … 2816 3011 Assert(cb == 4); Assert((offReg & 3) == 0); 2817 3012 3013 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); 3014 2818 3015 if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL) 2819 3016 LogFunc(("Access to registers except GCTL is blocked while reset\n")); … … 2824 3021 if (idxRegDsc != -1) 2825 3022 { 3023 /* Leave lock before calling read function. */ 3024 DEVHDA_UNLOCK(pThis); 3025 2826 3026 /* ASSUMES gapless DWORD at end of map. */ 2827 3027 if (g_aHdaRegMap[idxRegDsc].size == 4) … … 2865 3065 else 2866 3066 { 3067 DEVHDA_UNLOCK(pThis); 3068 2867 3069 rc = VINF_IOM_MMIO_UNUSED_FF; 2868 3070 Log3Func(("\tHole at %x is accessed for read\n", offReg)); … … 2886 3088 DECLINLINE(int) hdaWriteReg(PHDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog) 2887 3089 { 3090 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); 3091 2888 3092 if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL) 2889 3093 { … … 2891 3095 LogRel2(("HDA: Warning: Access to register %s is blocked while controller is in reset mode\n", 2892 3096 g_aHdaRegMap[idxRegDsc].abbrev)); 3097 3098 DEVHDA_UNLOCK(pThis); 2893 3099 return VINF_SUCCESS; 2894 3100 } … … 2916 3122 LogRel2(("HDA: Warning: Access to register %s is blocked while the stream's RUN bit is set\n", 2917 3123 g_aHdaRegMap[idxRegDsc].abbrev)); 3124 3125 DEVHDA_UNLOCK(pThis); 2918 3126 return VINF_SUCCESS; 2919 3127 } 2920 3128 } 3129 3130 /* Leave the lock before calling write function. */ 3131 DEVHDA_UNLOCK(pThis); 2921 3132 2922 3133 #ifdef LOG_ENABLED … … 4120 4331 4121 4332 LogFlowFuncEnter(); 4333 4334 DEVHDA_LOCK_RETURN_VOID(pThis); 4335 4122 4336 /* 4123 4337 * 18.2.6,7 defines that values of this registers might be cleared on power on/reset … … 4132 4346 */ 4133 4347 HDA_REG(pThis, GCTL) = HDA_GCTL_CRST; 4348 4349 DEVHDA_UNLOCK(pThis); 4134 4350 } 4135 4351 … … 4140 4356 { 4141 4357 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4358 4359 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 4142 4360 4143 4361 PHDADRIVER pDrv; … … 4166 4384 for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) 4167 4385 hdaStreamDestroy(&pThis->aStreams[i]); 4386 4387 DEVHDA_UNLOCK(pThis); 4168 4388 4169 4389 return VINF_SUCCESS; … … 4260 4480 static DECLCALLBACK(int) hdaAttach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 4261 4481 { 4262 return hdaAttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags); 4482 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4483 4484 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); 4485 4486 int rc = hdaAttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags); 4487 4488 DEVHDA_UNLOCK(pThis); 4489 4490 return rc; 4263 4491 } 4264 4492 … … 4277 4505 { 4278 4506 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4507 4508 DEVHDA_LOCK_RETURN_VOID(pThis); 4279 4509 4280 4510 LogRel2(("HDA: Powering off ...\n")); … … 4293 4523 pThis->pMixer = NULL; 4294 4524 } 4525 4526 DEVHDA_UNLOCK(pThis); 4295 4527 } 4296 4528
Note:
See TracChangeset
for help on using the changeset viewer.