Changeset 90447 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Jul 31, 2021 12:44:13 AM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevE1000.cpp
r90332 r90447 1657 1657 #endif /* IN_RING3 */ 1658 1658 1659 #define e1kCsEnter(ps, rc) PDMDevHlpCritSectEnter(pDevIns, &ps->cs, rc) 1660 #define e1kCsLeave(ps) PDMDevHlpCritSectLeave(pDevIns, &ps->cs) 1661 1662 #define e1kCsRxEnter(ps, rc) PDMDevHlpCritSectEnter(pDevIns, &ps->csRx, rc) 1663 #define e1kCsRxLeave(ps) PDMDevHlpCritSectLeave(pDevIns, &ps->csRx) 1664 #define e1kCsRxIsOwner(ps) PDMDevHlpCritSectIsOwner(pDevIns, &ps->csRx) 1659 1660 #define e1kCsEnter(ps, rcBusy) PDMDevHlpCritSectEnter(pDevIns, &(ps)->cs, (rcBusy)) 1661 #define e1kCsEnterReturn(ps, rcBusy) do { \ 1662 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &(ps)->cs, (rcBusy)); \ 1663 if (rcLock == VINF_SUCCESS) { /* likely */ } \ 1664 else return rcLock; \ 1665 } while (0) 1666 #define e1kR3CsEnterAsserted(ps) do { \ 1667 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &(ps)->cs, VERR_SEM_BUSY); \ 1668 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &(ps)->cs, rcLock); \ 1669 } while (0) 1670 #define e1kCsLeave(ps) PDMDevHlpCritSectLeave(pDevIns, &(ps)->cs) 1671 1672 1673 #define e1kCsRxEnter(ps, rcBusy) PDMDevHlpCritSectEnter(pDevIns, &(ps)->csRx, (rcBusy)) 1674 #define e1kCsRxEnterReturn(ps) do { \ 1675 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &(ps)->csRx, VERR_SEM_BUSY); \ 1676 AssertRCReturn(rcLock, rcLock); \ 1677 } while (0) 1678 #define e1kR3CsRxEnterAsserted(ps) do { \ 1679 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &(ps)->csRx, VERR_SEM_BUSY); \ 1680 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &(ps)->csRx, rcLock); \ 1681 } while (0) 1682 #define e1kCsRxLeave(ps) PDMDevHlpCritSectLeave(pDevIns, &(ps)->csRx) 1683 #define e1kCsRxIsOwner(ps) PDMDevHlpCritSectIsOwner(pDevIns, &(ps)->csRx) 1684 1665 1685 1666 1686 #ifndef E1K_WITH_TX_CS 1667 # define e1kCsTxEnter(ps, rc) VINF_SUCCESS 1687 # define e1kCsTxEnter(ps, rcBusy) VINF_SUCCESS 1688 # define e1kR3CsTxEnterAsserted(ps) do { } while (0) 1668 1689 # define e1kCsTxLeave(ps) do { } while (0) 1669 1690 #else /* E1K_WITH_TX_CS */ 1670 # define e1kCsTxEnter(ps, rc) PDMDevHlpCritSectEnter(pDevIns, &ps->csTx, rc) 1671 # define e1kCsTxLeave(ps) PDMDevHlpCritSectLeave(pDevIns, &ps->csTx) 1672 # define e1kCsTxIsOwner(ps) PDMDevHlpCritSectIsOwner(pDevIns, &ps->csTx) 1691 # define e1kCsTxEnter(ps, rcBusy) PDMDevHlpCritSectEnter(pDevIns, &(ps)->csTx, (rcBusy)) 1692 # define e1kR3CsTxEnterAsserted(ps) do { \ 1693 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &(ps)->csTx, VERR_SEM_BUSY); \ 1694 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &(ps)->csTx, rcLock); \ 1695 } while (0) 1696 # define e1kCsTxLeave(ps) PDMDevHlpCritSectLeave(pDevIns, &(ps)->csTx) 1697 # define e1kCsTxIsOwner(ps) PDMDevHlpCritSectIsOwner(pDevIns, &(ps)->csTx) 1673 1698 #endif /* E1K_WITH_TX_CS */ 1674 1699 … … 1799 1824 memset(pThis->auRegs, 0, sizeof(pThis->auRegs)); 1800 1825 memset(pThis->aRecAddr.au32, 0, sizeof(pThis->aRecAddr.au32)); 1801 # ifdef E1K_INIT_RA01826 # ifdef E1K_INIT_RA0 1802 1827 memcpy(pThis->aRecAddr.au32, pThis->macConfigured.au8, 1803 1828 sizeof(pThis->macConfigured.au8)); 1804 1829 pThis->aRecAddr.array[0].ctl |= RA_CTL_AV; 1805 # endif /* E1K_INIT_RA0 */1830 # endif /* E1K_INIT_RA0 */ 1806 1831 STATUS = 0x0081; /* SPEED=10b (1000 Mb/s), FD=1b (Full Duplex) */ 1807 1832 EECD = 0x0100; /* EE_PRES=1b (EEPROM present) */ … … 1819 1844 pThisCC->pDrvR3->pfnSetPromiscuousMode(pThisCC->pDrvR3, false); 1820 1845 1821 #ifdef E1K_WITH_TXD_CACHE 1822 int rc = e1kCsTxEnter(pThis, VERR_SEM_BUSY); 1823 if (RT_LIKELY(rc == VINF_SUCCESS)) 1824 { 1825 pThis->nTxDFetched = 0; 1826 pThis->iTxDCurrent = 0; 1827 pThis->fGSO = false; 1828 pThis->cbTxAlloc = 0; 1829 e1kCsTxLeave(pThis); 1830 } 1831 #endif /* E1K_WITH_TXD_CACHE */ 1832 #ifdef E1K_WITH_RXD_CACHE 1833 if (RT_LIKELY(e1kCsRxEnter(pThis, VERR_SEM_BUSY) == VINF_SUCCESS)) 1834 { 1835 pThis->iRxDCurrent = pThis->nRxDFetched = 0; 1836 e1kCsRxLeave(pThis); 1837 } 1838 #endif /* E1K_WITH_RXD_CACHE */ 1839 #ifdef E1K_LSC_ON_RESET 1846 # ifdef E1K_WITH_TXD_CACHE 1847 e1kR3CsTxEnterAsserted(pThis); 1848 pThis->nTxDFetched = 0; 1849 pThis->iTxDCurrent = 0; 1850 pThis->fGSO = false; 1851 pThis->cbTxAlloc = 0; 1852 e1kCsTxLeave(pThis); 1853 # endif /* E1K_WITH_TXD_CACHE */ 1854 # ifdef E1K_WITH_RXD_CACHE 1855 e1kR3CsRxEnterAsserted(pThis); 1856 pThis->iRxDCurrent = pThis->nRxDFetched = 0; 1857 e1kCsRxLeave(pThis); 1858 # endif /* E1K_WITH_RXD_CACHE */ 1859 # ifdef E1K_LSC_ON_RESET 1840 1860 E1kLog(("%s Will trigger LSC in %d seconds...\n", 1841 1861 pThis->szPrf, pThis->cMsLinkUpDelay / 1000)); 1842 1862 e1kArmTimer(pDevIns, pThis, pThis->hLUTimer, pThis->cMsLinkUpDelay * 1000); 1843 # endif /* E1K_LSC_ON_RESET */1863 # endif /* E1K_LSC_ON_RESET */ 1844 1864 } 1845 1865 … … 2184 2204 static int e1kRaiseInterrupt(PPDMDEVINS pDevIns, PE1KSTATE pThis, int rcBusy, uint32_t u32IntCause) 2185 2205 { 2206 /* Do NOT use e1kCsEnterReturn here as most callers doesn't check the 2207 status code. They'll pass a negative rcBusy. */ 2186 2208 int rc = e1kCsEnter(pThis, rcBusy); 2187 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 2209 if (RT_LIKELY(rc == VINF_SUCCESS)) 2210 { /* likely */ } 2211 else 2212 { 2213 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->cs, rc); 2188 2214 return rc; 2215 } 2189 2216 2190 2217 E1K_INC_ISTAT_CNT(pThis->uStatIntTry); … … 2265 2292 { 2266 2293 Assert(e1kCsRxIsOwner(pThis)); 2267 //e1k CsEnter(pThis, RT_SRC_POS);2294 //e1kR3CsEnterAsserted(pThis); 2268 2295 if (++pRxdc->rdh * sizeof(E1KRXDESC) >= pRxdc->rdlen) 2269 2296 pRxdc->rdh = 0; … … 2535 2562 * 2536 2563 * @returns VBox status code. 2537 * @param pDevIns The device instance.2538 * @param pThis The device state structure.2564 * @param pDevIns The device instance. 2565 * @param pThis The device state structure. 2539 2566 * @param pvBuf The available data. 2540 2567 * @param cb Number of bytes available in the buffer. … … 2550 2577 # endif /* E1K_WITH_RXD_CACHE */ 2551 2578 2552 int rc = e1kCsRxEnter(pThis, VERR_SEM_BUSY); 2553 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 2554 return rc; 2579 e1kCsRxEnterReturn(pThis); 2555 2580 # ifdef E1K_WITH_RXD_CACHE 2556 2581 if (RT_UNLIKELY(!e1kUpdateRxDContext(pDevIns, pThis, &rxdc, "e1kHandleRxPacket"))) … … 2686 2711 e1kCsRxLeave(pThis); 2687 2712 e1kStoreRxFragment(pDevIns, pThis, pDesc, ptr, u16RxBufferSize); 2688 rc = e1kCsRxEnter(pThis, VERR_SEM_BUSY); 2689 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 2690 return rc; 2713 e1kCsRxEnterReturn(pThis); 2691 2714 # ifdef E1K_WITH_RXD_CACHE 2692 2715 if (RT_UNLIKELY(!e1kUpdateRxDContext(pDevIns, pThis, &rxdc, "e1kHandleRxPacket"))) … … 2706 2729 e1kStoreRxFragment(pDevIns, pThis, pDesc, ptr, cb); 2707 2730 # ifdef E1K_WITH_RXD_CACHE 2708 rc = e1kCsRxEnter(pThis, VERR_SEM_BUSY); 2709 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 2710 return rc; 2731 e1kCsRxEnterReturn(pThis); 2711 2732 if (RT_UNLIKELY(!e1kUpdateRxDContext(pDevIns, pThis, &rxdc, "e1kHandleRxPacket"))) 2712 2733 { … … 3212 3233 static int e1kRegReadICR(PPDMDEVINS pDevIns, PE1KSTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 3213 3234 { 3214 int rc = e1kCsEnter(pThis, VINF_IOM_R3_MMIO_READ); 3215 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 3216 return rc; 3235 e1kCsEnterReturn(pThis, VINF_IOM_R3_MMIO_READ); 3217 3236 3218 3237 uint32_t value = 0; 3219 rc = e1kRegReadDefault(pDevIns, pThis, offset, index, &value);3238 int rc = e1kRegReadDefault(pDevIns, pThis, offset, index, &value); 3220 3239 if (RT_SUCCESS(rc)) 3221 3240 { … … 3349 3368 RT_NOREF_PV(offset); RT_NOREF_PV(index); 3350 3369 3351 int rc = e1kCsEnter(pThis, VINF_IOM_R3_MMIO_WRITE); 3352 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 3353 return rc; 3370 e1kCsEnterReturn(pThis, VINF_IOM_R3_MMIO_WRITE); 3354 3371 if (pThis->fIntRaised) 3355 3372 { … … 3674 3691 /* 3675 3692 * This can happen if we set the link status to down when the Link up timer was 3676 * already armed (shortly after e1k LoadDone() or when the cable was disconnected3693 * already armed (shortly after e1kR3LoadDone() or when the cable was disconnected 3677 3694 * and connect+disconnect the cable very quick. Moreover, 82543GC triggers LSC 3678 3695 * on reset even if the cable is unplugged (see @bugref{8942}). … … 4242 4259 rc = pDrv->pfnSendBuf(pDrv, pSg, fOnWorkerThread); 4243 4260 STAM_PROFILE_STOP(&pThis->CTX_SUFF_Z(StatTransmitSend), a); 4244 //e1k CsEnter(pThis, RT_SRC_POS);4261 //e1kR3CsEnterAsserted(pThis); 4245 4262 } 4246 4263 } … … 6212 6229 * Mask out irrelevant bits. 6213 6230 */ 6214 //rc = e1kCsEnter(pThis, VERR_SEM_BUSY, RT_SRC_POS); 6215 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 6216 return rc; 6231 //e1kCsEnterReturn(pThis, VERR_SEM_BUSY); 6217 6232 //pThis->fDelayInts = false; 6218 6233 //pThis->iStatIntLost += pThis->iStatIntLostOne; … … 6273 6288 * Mask out irrelevant bits. 6274 6289 */ 6275 //rc = e1kCsEnter(pThis, VERR_SEM_BUSY, RT_SRC_POS); 6276 //if (RT_UNLIKELY(rc != VINF_SUCCESS)) 6277 // return rc; 6290 //e1kCsEnterReturn(pThis, VERR_SEM_BUSY); 6278 6291 //pThis->fDelayInts = false; 6279 6292 //pThis->iStatIntLost += pThis->iStatIntLostOne; … … 6323 6336 Log6(("%s At %08X write %08X to %s (%s)\n", 6324 6337 pThis->szPrf, offReg, u32Value, g_aE1kRegMap[index].abbrev, g_aE1kRegMap[index].name)); 6325 //rc = e1kCsEnter(pThis, VERR_SEM_BUSY, RT_SRC_POS); 6326 //if (RT_UNLIKELY(rc != VINF_SUCCESS)) 6327 // return rc; 6338 //e1kCsEnterReturn(pThis, VERR_SEM_BUSY); 6328 6339 //pThis->fDelayInts = false; 6329 6340 //pThis->iStatIntLost += pThis->iStatIntLostOne; … … 6543 6554 * This must be called before the pfnRecieve() method is called. 6544 6555 * 6545 * @returns Number of bytes the device can receive. 6556 * @returns VBox status code. 6557 * @retval VERR_NET_NO_BUFFER_SPACE if we cannot receive. 6546 6558 * @param pDevIns The device instance. 6547 6559 * @param pThis The instance data. 6548 6560 * @thread EMT 6549 6561 */ 6550 static int e1k CanReceive(PPDMDEVINS pDevIns, PE1KSTATE pThis)6551 { 6552 # ifndef E1K_WITH_RXD_CACHE6562 static int e1kR3CanReceive(PPDMDEVINS pDevIns, PE1KSTATE pThis) 6563 { 6564 # ifndef E1K_WITH_RXD_CACHE 6553 6565 size_t cb; 6554 6566 6555 if (RT_UNLIKELY(e1kCsRxEnter(pThis, VERR_SEM_BUSY) != VINF_SUCCESS)) 6556 return VERR_NET_NO_BUFFER_SPACE; 6567 e1kCsRxEnterReturn(pThis); 6557 6568 6558 6569 if (RT_UNLIKELY(RDLEN == sizeof(E1KRXDESC))) … … 6568 6579 cb = (RDT - RDH) * pThis->u16RxBSize; 6569 6580 else if (RDH > RDT) 6570 cb = (RDLEN /sizeof(E1KRXDESC) - RDH + RDT) * pThis->u16RxBSize;6581 cb = (RDLEN / sizeof(E1KRXDESC) - RDH + RDT) * pThis->u16RxBSize; 6571 6582 else 6572 6583 { … … 6574 6585 E1kLogRel(("E1000: OUT of RX descriptors!\n")); 6575 6586 } 6576 E1kLog2(("%s e1k CanReceive: at exit RDH=%d RDT=%d RDLEN=%d u16RxBSize=%d cb=%lu\n",6587 E1kLog2(("%s e1kR3CanReceive: at exit RDH=%d RDT=%d RDLEN=%d u16RxBSize=%d cb=%lu\n", 6577 6588 pThis->szPrf, RDH, RDT, RDLEN, pThis->u16RxBSize, cb)); 6578 6589 6579 6590 e1kCsRxLeave(pThis); 6580 6591 return cb > 0 ? VINF_SUCCESS : VERR_NET_NO_BUFFER_SPACE; 6581 #else /* E1K_WITH_RXD_CACHE */ 6592 # else /* E1K_WITH_RXD_CACHE */ 6593 6594 e1kCsRxEnterReturn(pThis); 6595 6596 E1KRXDC rxdc; 6597 if (RT_UNLIKELY(!e1kUpdateRxDContext(pDevIns, pThis, &rxdc, "e1kR3CanReceive"))) 6598 { 6599 e1kCsRxLeave(pThis); 6600 E1kLog(("%s e1kR3CanReceive: failed to update Rx context, returning VERR_NET_NO_BUFFER_SPACE\n", pThis->szPrf)); 6601 return VERR_NET_NO_BUFFER_SPACE; 6602 } 6603 6582 6604 int rc = VINF_SUCCESS; 6583 6584 if (RT_UNLIKELY(e1kCsRxEnter(pThis, VERR_SEM_BUSY) != VINF_SUCCESS))6585 return VERR_NET_NO_BUFFER_SPACE;6586 E1KRXDC rxdc;6587 if (RT_UNLIKELY(!e1kUpdateRxDContext(pDevIns, pThis, &rxdc, "e1kCanReceive")))6588 {6589 e1kCsRxLeave(pThis);6590 E1kLog(("%s e1kCanReceive: failed to update Rx context, returning VERR_NET_NO_BUFFER_SPACE\n", pThis->szPrf));6591 return VERR_NET_NO_BUFFER_SPACE;6592 }6593 6594 6605 if (RT_UNLIKELY(rxdc.rdlen == sizeof(E1KRXDESC))) 6595 6606 { … … 6604 6615 rc = VERR_NET_NO_BUFFER_SPACE; 6605 6616 } 6606 E1kLog2(("%s e1kCanReceive: at exit in_cache=%d RDH=%d RDT=%d RDLEN=%d" 6607 " u16RxBSize=%d rc=%Rrc\n", pThis->szPrf, 6617 E1kLog2(("%s e1kR3CanReceive: at exit in_cache=%d RDH=%d RDT=%d RDLEN=%d u16RxBSize=%d rc=%Rrc\n", pThis->szPrf, 6608 6618 e1kRxDInCache(pThis), rxdc.rdh, rxdc.rdt, rxdc.rdlen, pThis->u16RxBSize, rc)); 6609 6619 6610 6620 e1kCsRxLeave(pThis); 6611 6621 return rc; 6612 # endif /* E1K_WITH_RXD_CACHE */6622 # endif /* E1K_WITH_RXD_CACHE */ 6613 6623 } 6614 6624 … … 6622 6632 PPDMDEVINS pDevIns = pThisCC->pDevInsR3; 6623 6633 6624 int rc = e1kCanReceive(pDevIns, pThis); 6625 6634 int rc = e1kR3CanReceive(pDevIns, pThis); 6626 6635 if (RT_SUCCESS(rc)) 6627 6636 return VINF_SUCCESS; 6637 6628 6638 if (RT_UNLIKELY(cMillies == 0)) 6629 6639 return VERR_NET_NO_BUFFER_SPACE; … … 6636 6646 || enmVMState == VMSTATE_RUNNING_LS)) 6637 6647 { 6638 int rc2 = e1k CanReceive(pDevIns, pThis);6648 int rc2 = e1kR3CanReceive(pDevIns, pThis); 6639 6649 if (RT_SUCCESS(rc2)) 6640 6650 { … … 6864 6874 STAM_PROFILE_ADV_START(&pThis->StatReceive, a); 6865 6875 6866 //if (!e1kCsEnter(pThis, RT_SRC_POS)) 6867 // return VERR_PERMISSION_DENIED; 6876 //e1kR3CsEnterAsserted(pThis); 6868 6877 6869 6878 e1kPacketDump(pDevIns, pThis, (const uint8_t*)pvBuf, cb, "<-- Incoming"); 6870 6879 6871 6880 /* Update stats */ 6872 if (RT_LIKELY(e1kCsEnter(pThis, VERR_SEM_BUSY) == VINF_SUCCESS)) 6873 { 6874 E1K_INC_CNT32(TPR); 6875 E1K_ADD_CNT64(TORL, TORH, cb < 64? 64 : cb); 6876 e1kCsLeave(pThis); 6877 } 6881 e1kR3CsEnterAsserted(pThis); 6882 E1K_INC_CNT32(TPR); 6883 E1K_ADD_CNT64(TORL, TORH, cb < 64? 64 : cb); 6884 e1kCsLeave(pThis); 6885 6878 6886 STAM_PROFILE_ADV_START(&pThis->StatReceiveFilter, a); 6879 6887 E1KRXDST status; … … 7001 7009 * @param pSSM The handle to the saved state. 7002 7010 */ 7003 static void e1k SaveConfig(PCPDMDEVHLPR3 pHlp, PE1KSTATE pThis, PSSMHANDLE pSSM)7011 static void e1kR3SaveConfig(PCPDMDEVHLPR3 pHlp, PE1KSTATE pThis, PSSMHANDLE pSSM) 7004 7012 { 7005 7013 pHlp->pfnSSMPutMem(pSSM, &pThis->macConfigured, sizeof(pThis->macConfigured)); … … 7010 7018 * @callback_method_impl{FNSSMDEVLIVEEXEC,Save basic configuration.} 7011 7019 */ 7012 static DECLCALLBACK(int) e1k LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)7020 static DECLCALLBACK(int) e1kR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 7013 7021 { 7014 7022 RT_NOREF(uPass); 7015 e1k SaveConfig(pDevIns->pHlpR3, PDMDEVINS_2_DATA(pDevIns, PE1KSTATE), pSSM);7023 e1kR3SaveConfig(pDevIns->pHlpR3, PDMDEVINS_2_DATA(pDevIns, PE1KSTATE), pSSM); 7016 7024 return VINF_SSM_DONT_CALL_AGAIN; 7017 7025 } … … 7020 7028 * @callback_method_impl{FNSSMDEVSAVEPREP,Synchronize.} 7021 7029 */ 7022 static DECLCALLBACK(int) e1k SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)7030 static DECLCALLBACK(int) e1kR3SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 7023 7031 { 7024 7032 RT_NOREF(pSSM); 7025 7033 PE1KSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PE1KSTATE); 7026 7034 7027 int rc = e1kCsEnter(pThis, VERR_SEM_BUSY); 7028 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 7029 return rc; 7035 e1kCsEnterReturn(pThis, VERR_SEM_BUSY); 7030 7036 e1kCsLeave(pThis); 7031 7037 return VINF_SUCCESS; … … 7060 7066 * @callback_method_impl{FNSSMDEVSAVEEXEC} 7061 7067 */ 7062 static DECLCALLBACK(int) e1k SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)7068 static DECLCALLBACK(int) e1kR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 7063 7069 { 7064 7070 PE1KSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PE1KSTATE); … … 7066 7072 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 7067 7073 7068 e1k SaveConfig(pHlp, pThis, pSSM);7074 e1kR3SaveConfig(pHlp, pThis, pSSM); 7069 7075 pThisCC->eeprom.save(pHlp, pSSM); 7070 7076 e1kDumpState(pThis); … … 7130 7136 * @callback_method_impl{FNSSMDEVLOADPREP,Synchronize.} 7131 7137 */ 7132 static DECLCALLBACK(int) e1k LoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)7138 static DECLCALLBACK(int) e1kR3LoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 7133 7139 { 7134 7140 RT_NOREF(pSSM); 7135 7141 PE1KSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PE1KSTATE); 7136 7142 7137 int rc = e1kCsEnter(pThis, VERR_SEM_BUSY); 7138 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 7139 return rc; 7143 e1kCsEnterReturn(pThis, VERR_SEM_BUSY); 7140 7144 e1kCsLeave(pThis); 7141 7145 return VINF_SUCCESS; … … 7145 7149 * @callback_method_impl{FNSSMDEVLOADEXEC} 7146 7150 */ 7147 static DECLCALLBACK(int) e1k LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)7151 static DECLCALLBACK(int) e1kR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 7148 7152 { 7149 7153 PE1KSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PE1KSTATE); … … 7257 7261 * @callback_method_impl{FNSSMDEVLOADDONE, Link status adjustments after loading.} 7258 7262 */ 7259 static DECLCALLBACK(int) e1k LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)7263 static DECLCALLBACK(int) e1kR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 7260 7264 { 7261 7265 PE1KSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PE1KSTATE); … … 7288 7292 * @callback_method_impl{FNRTSTRFORMATTYPE} 7289 7293 */ 7290 static DECLCALLBACK(size_t) e1k FmtRxDesc(PFNRTSTROUTPUT pfnOutput,7291 void *pvArgOutput,7292 const char *pszType,7293 void const *pvValue,7294 int cchWidth,7295 int cchPrecision,7296 unsigned fFlags,7297 void *pvUser)7294 static DECLCALLBACK(size_t) e1kR3FmtRxDesc(PFNRTSTROUTPUT pfnOutput, 7295 void *pvArgOutput, 7296 const char *pszType, 7297 void const *pvValue, 7298 int cchWidth, 7299 int cchPrecision, 7300 unsigned fFlags, 7301 void *pvUser) 7298 7302 { 7299 7303 RT_NOREF(cchWidth, cchPrecision, fFlags, pvUser); … … 7327 7331 * @callback_method_impl{FNRTSTRFORMATTYPE} 7328 7332 */ 7329 static DECLCALLBACK(size_t) e1k FmtTxDesc(PFNRTSTROUTPUT pfnOutput,7330 void *pvArgOutput,7331 const char *pszType,7332 void const *pvValue,7333 int cchWidth,7334 int cchPrecision,7335 unsigned fFlags,7336 void *pvUser)7333 static DECLCALLBACK(size_t) e1kR3FmtTxDesc(PFNRTSTROUTPUT pfnOutput, 7334 void *pvArgOutput, 7335 const char *pszType, 7336 void const *pvValue, 7337 int cchWidth, 7338 int cchPrecision, 7339 unsigned fFlags, 7340 void *pvUser) 7337 7341 { 7338 7342 RT_NOREF(cchWidth, cchPrecision, fFlags, pvUser); … … 7412 7416 7413 7417 /** Initializes debug helpers (logging format types). */ 7414 static int e1k InitDebugHelpers(void)7418 static int e1kR3InitDebugHelpers(void) 7415 7419 { 7416 7420 int rc = VINF_SUCCESS; … … 7419 7423 { 7420 7424 s_fHelpersRegistered = true; 7421 rc = RTStrFormatTypeRegister("e1krxd", e1k FmtRxDesc, NULL);7425 rc = RTStrFormatTypeRegister("e1krxd", e1kR3FmtRxDesc, NULL); 7422 7426 AssertRCReturn(rc, rc); 7423 rc = RTStrFormatTypeRegister("e1ktxd", e1k FmtTxDesc, NULL);7427 rc = RTStrFormatTypeRegister("e1ktxd", e1kR3FmtTxDesc, NULL); 7424 7428 AssertRCReturn(rc, rc); 7425 7429 } … … 7434 7438 * @param pszArgs The arguments. 7435 7439 */ 7436 static DECLCALLBACK(void) e1k Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)7440 static DECLCALLBACK(void) e1kR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 7437 7441 { 7438 7442 RT_NOREF(pszArgs); … … 7461 7465 pDevIns->fRCEnabled ? " RC" : "", pDevIns->fR0Enabled ? " R0" : ""); 7462 7466 7463 e1k CsEnter(pThis, VERR_INTERNAL_ERROR); /* Not sure why but PCNet does it */7467 e1kR3CsEnterAsserted(pThis); /* Not sure why but PCNet does it */ 7464 7468 7465 7469 for (i = 0; i < E1K_NUM_OF_32BIT_REGS; ++i) … … 7614 7618 AssertLogRelReturnVoid(iLUN == 0); 7615 7619 7616 PDMDevHlpCritSectEnter(pDevIns, &pThis->cs, VERR_SEM_BUSY); 7617 7618 /** @todo r=pritesh still need to check if i missed 7619 * to clean something in this function 7620 */ 7620 e1kR3CsEnterAsserted(pThis); 7621 7621 7622 7622 /* … … 7654 7654 AssertLogRelReturn(iLUN == 0, VERR_PDM_NO_SUCH_LUN); 7655 7655 7656 PDMDevHlpCritSectEnter(pDevIns, &pThis->cs, VERR_SEM_BUSY);7656 e1kR3CsEnterAsserted(pThis); 7657 7657 7658 7658 /* … … 8031 8031 /* Saved state registration. */ 8032 8032 rc = PDMDevHlpSSMRegisterEx(pDevIns, E1K_SAVEDSTATE_VERSION, sizeof(E1KSTATE), NULL, 8033 NULL, e1k LiveExec, NULL,8034 e1k SavePrep, e1kSaveExec, NULL,8035 e1k LoadPrep, e1kLoadExec, e1kLoadDone);8033 NULL, e1kR3LiveExec, NULL, 8034 e1kR3SavePrep, e1kR3SaveExec, NULL, 8035 e1kR3LoadPrep, e1kR3LoadExec, e1kR3LoadDone); 8036 8036 AssertRCReturn(rc, rc); 8037 8037 … … 8136 8136 char szTmp[20]; 8137 8137 RTStrPrintf(szTmp, sizeof(szTmp), "e1k%d", iInstance); 8138 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "E1000 info.", e1k Info);8138 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "E1000 info.", e1kR3Info); 8139 8139 8140 8140 /* Status driver */ … … 8169 8169 AssertRCReturn(rc, rc); 8170 8170 8171 rc = e1k InitDebugHelpers();8171 rc = e1kR3InitDebugHelpers(); 8172 8172 AssertRCReturn(rc, rc); 8173 8173 -
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r88498 r90447 1338 1338 ) 1339 1339 { 1340 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 1341 AssertReleaseRC(rc); 1340 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 1341 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock); 1342 1342 1343 /* Check if we can do something now */ 1343 1344 pcnetPollRxTx(pDevIns, pThis, pThisCC); 1344 1345 pcnetUpdateIrq(pDevIns, pThis); 1346 1345 1347 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 1346 1348 } … … 2038 2040 pcnetPhysWrite(pDevIns, pThis, rbadr, src, cbBuf); 2039 2041 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 2040 AssertReleaseRC(rc);2042 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rc); 2041 2043 2042 2044 /* RX disabled in the meantime? If so, abort RX. */ … … 2085 2087 pcnetPhysWrite(pDevIns, pThis, rbadr2, src, cbBuf); 2086 2088 rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 2087 AssertReleaseRC(rc);2089 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rc); 2088 2090 2089 2091 /* RX disabled in the meantime? If so, abort RX. */ … … 4048 4050 4049 4051 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4050 AssertReleaseRC(rc);4052 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rc); 4051 4053 4052 4054 rc = VERR_GENERAL_FAILURE; … … 4168 4170 4169 4171 4170 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_INTERNAL_ERROR); /* Take it here so we know why we're hanging... */ 4172 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_INTERNAL_ERROR); /* Take it here so we know why we're hanging... */ 4173 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock); 4171 4174 4172 4175 pHlp->pfnPrintf(pHlp, … … 4471 4474 4472 4475 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4473 AssertRC (rc);4476 AssertRCReturn(rc, rc); 4474 4477 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 4475 4476 4478 return VINF_SUCCESS; 4477 4479 } … … 4524 4526 4525 4527 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4526 AssertRC (rc);4528 AssertRCReturn(rc, rc); 4527 4529 4528 4530 uint32_t uVer = pHlp->pfnSSMHandleVersion(pSSM); … … 4682 4684 { 4683 4685 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4684 AssertReleaseRC(rc);4686 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rc); 4685 4687 4686 4688 rc = VERR_NET_NO_BUFFER_SPACE; … … 4738 4740 * is true -- even if (transmit) polling is disabled (CSR_DPOLL). */ 4739 4741 rc2 = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4740 AssertReleaseRC(rc2);4742 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rc2); 4741 4743 #ifndef PCNET_NO_POLLING 4742 4744 pcnetPollTimerStart(pDevIns, pThis); … … 4763 4765 STAM_PROFILE_ADV_START(&pThis->StatReceive, a); 4764 4766 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4765 AssertReleaseRC(rc);4767 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rc); 4766 4768 4767 4769 /* … … 4968 4970 AssertLogRelReturnVoid(iLUN == 0); 4969 4971 4970 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4972 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 4973 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock); 4971 4974 4972 4975 /** @todo r=pritesh still need to check if i missed … … 5001 5004 AssertLogRelReturn(iLUN == 0, VERR_PDM_NO_SUCH_LUN); 5002 5005 5003 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 5006 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY); 5007 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, &pThis->CritSect, rcLock); 5004 5008 5005 5009 /* -
trunk/src/VBox/Devices/Network/DevVirtioNet.cpp
r90156 r90447 328 328 return !!(pThis->VPCI.uGuestFeatures & VNET_F_MRG_RXBUF); 329 329 } 330 331 #define VNET_R3_CS_ENTER_RETURN_VOID(a_pDevIns, a_pThis) VPCI_R3_CS_ENTER_RETURN_VOID(a_pDevIns, &(a_pThis)->VPCI) 330 332 331 333 DECLINLINE(int) vnetR3CsEnter(PPDMDEVINS pDevIns, PVNETSTATE pThis, int rcBusy) … … 648 650 RT_NOREF(hTimer, pvUser); 649 651 650 int rc = vnetR3CsEnter(pDevIns, pThis, VERR_SEM_BUSY); 651 AssertRCReturnVoid(rc); 652 VNET_R3_CS_ENTER_RETURN_VOID(pDevIns, pThis); 652 653 653 654 pThis->config.uStatus |= VNET_S_LINK_UP; … … 1509 1510 Log3(("%s vnetR3QueueTransmit: Got kicked with notification disabled, re-enable notification and flush TX queue\n", INSTANCE(pThis))); 1510 1511 vnetR3TransmitPendingPackets(pDevIns, pThis, pThisCC, pQueue, false /*fOnWorkerThread*/); 1511 if (RT_FAILURE(vnetR3CsEnter(pDevIns, pThis, VERR_SEM_BUSY))) 1512 LogRel(("vnetR3QueueTransmit: Failed to enter critical section!/n")); 1513 else 1514 { 1515 vringSetNotification(pDevIns, &pThisCC->pTxQueue->VRing, true); 1516 vnetR3CsLeave(pDevIns, pThis); 1517 } 1512 1513 VNET_R3_CS_ENTER_RETURN_VOID(pDevIns, pThis); 1514 1515 vringSetNotification(pDevIns, &pThisCC->pTxQueue->VRing, true); 1516 1517 vnetR3CsLeave(pDevIns, pThis); 1518 1518 } 1519 1519 else 1520 1520 { 1521 if (RT_FAILURE(vnetR3CsEnter(pDevIns, pThis, VERR_SEM_BUSY))) 1522 LogRel(("vnetR3QueueTransmit: Failed to enter critical section!/n")); 1523 else 1524 { 1525 vringSetNotification(pDevIns, &pThisCC->pTxQueue->VRing, false); 1526 PDMDevHlpTimerSetMicro(pDevIns, pThis->hTxTimer, VNET_TX_DELAY); 1527 pThis->u64NanoTS = RTTimeNanoTS(); 1528 vnetR3CsLeave(pDevIns, pThis); 1529 } 1521 VNET_R3_CS_ENTER_RETURN_VOID(pDevIns, pThis); 1522 1523 vringSetNotification(pDevIns, &pThisCC->pTxQueue->VRing, false); 1524 PDMDevHlpTimerSetMicro(pDevIns, pThis->hTxTimer, VNET_TX_DELAY); 1525 pThis->u64NanoTS = RTTimeNanoTS(); 1526 1527 vnetR3CsLeave(pDevIns, pThis); 1530 1528 } 1531 1529 } … … 1552 1550 // Log3(("%s vnetR3TxTimer: Expired\n", INSTANCE(pThis))); 1553 1551 vnetR3TransmitPendingPackets(pDevIns, pThis, pThisCC, pThisCC->pTxQueue, false /*fOnWorkerThread*/); 1554 int rc = vnetR3CsEnter(pDevIns, pThis, VERR_SEM_BUSY) 1555 AssertLogRelRCReturnVoid(rc);1552 1553 VNET_R3_CS_ENTER_RETURN_VOID(pDevIns, pThis); 1556 1554 vringSetNotification(pDevIns, &pThisCC->pTxQueue->VRing, true); 1557 1555 vnetR3CsLeave(pDevIns, pThis); … … 2043 2041 AssertLogRelReturnVoid(iLUN == 0); 2044 2042 2045 int rc = vnetR3CsEnter(pDevIns, pThis, VERR_SEM_BUSY); 2046 if (RT_FAILURE(rc)) 2047 { 2048 LogRel(("vnetR3Detach failed to enter critical section!\n")); 2049 return; 2050 } 2043 VNET_R3_CS_ENTER_RETURN_VOID(pDevIns, pThis); 2051 2044 2052 2045 vnetR3DestroyTxThreadAndEvent(pDevIns, pThis, pThisCC); … … 2075 2068 2076 2069 int rc = vnetR3CsEnter(pDevIns, pThis, VERR_SEM_BUSY); 2077 if (RT_FAILURE(rc)) 2078 { 2079 LogRel(("vnetR3Attach failed to enter critical section!\n")); 2080 return rc; 2081 } 2070 AssertRCReturn(rc, rc); 2082 2071 2083 2072 /*
Note:
See TracChangeset
for help on using the changeset viewer.