- Timestamp:
- Feb 18, 2015 2:15:18 PM (10 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r54252 r54262 4042 4042 * initially). The callback clears the methods not detected. */ 4043 4043 uint32_t volatile fSupported; 4044 /** The first callback detecting any kind of range issues (initializ sed to4044 /** The first callback detecting any kind of range issues (initialized to 4045 4045 * NIL_RTCPUID). */ 4046 4046 RTCPUID volatile idCpuProblem; … … 4137 4137 AssertCompile(sizeof(pState->bmApicId) * 8 == RT_ELEMENTS(pGip->aiCpuFromApicId)); 4138 4138 ASMAtomicCmpXchgU32(&pState->idCpuProblem, idCpu, NIL_RTCPUID); 4139 LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - duplicate APIC ID.\n", 4139 LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - duplicate APIC ID.\n", 4140 4140 idCpu, iCpuSet, idApic)); 4141 4141 } … … 4149 4149 { 4150 4150 ASMAtomicCmpXchgU32(&pState->idCpuProblem, idCpu, NIL_RTCPUID); 4151 LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - CPU set index is out of range.\n", 4151 LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - CPU set index is out of range.\n", 4152 4152 idCpu, iCpuSet, idApic)); 4153 4153 } … … 6120 6120 pDevExt->enmTscDeltaState = kSupDrvTscDeltaState_Listening; 6121 6121 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6122 pDevExt->rcTscDelta = rc; 6122 Assert(rc != VERR_NOT_AVAILABLE); /* VERR_NOT_AVAILABLE is used as the initial value. */ 6123 ASMAtomicWriteS32(&pDevExt->rcTscDelta, rc); 6123 6124 break; 6124 6125 } … … 6250 6251 static int supdrvTscDeltaThreadInit(PSUPDRVDEVEXT pDevExt) 6251 6252 { 6253 int rc; 6252 6254 Assert(pDevExt->pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED); 6253 6254 int rc = RTSpinlockCreate(&pDevExt->hTscDeltaSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "VBoxTscSpnLck"); 6255 rc = RTSpinlockCreate(&pDevExt->hTscDeltaSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "VBoxTscSpnLck"); 6255 6256 if (RT_SUCCESS(rc)) 6256 6257 { … … 6269 6270 if (RT_SUCCESS(rc)) 6270 6271 { 6271 pDevExt->rcTscDelta = VERR_NOT_AVAILABLE;6272 ASMAtomicWriteS32(&pDevExt->rcTscDelta, VERR_NOT_AVAILABLE); 6272 6273 return rc; 6273 6274 } … … 6318 6319 } 6319 6320 6320 pDevExt->rcTscDelta = VERR_NOT_AVAILABLE;6321 ASMAtomicWriteS32(&pDevExt->rcTscDelta, VERR_NOT_AVAILABLE); 6321 6322 } 6322 6323 … … 6337 6338 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 6338 6339 AssertReturn(pGip, VERR_INVALID_POINTER); 6340 6341 if (RT_UNLIKELY(pDevExt->hTscDeltaThread == NIL_RTTHREAD)) 6342 return VERR_THREAD_NOT_WAITABLE; 6339 6343 6340 6344 cMsTotalWait = RT_MIN(pGip->cPresentCpus + 2, 150); … … 6582 6586 u64DeltaTsc = u64Tsc - pDevExt->u64TscAnchor; 6583 6587 6584 if ( pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC6585 && !fDeltaApplied)6586 { 6587 SUPR0Printf("vboxdrv: failed to refine TSC frequency as TSC-deltas unavailable after %d seconds!\n",6588 GIP_TSC_REFINE_INTERVAL) ;6588 if (RT_UNLIKELY( pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_PRACTICALLY_ZERO 6589 && !fDeltaApplied)) 6590 { 6591 Log(("vboxdrv: failed to refine TSC frequency as TSC-deltas unavailable after %d seconds!\n", 6592 GIP_TSC_REFINE_INTERVAL)); 6589 6593 return; 6590 6594 } … … 6620 6624 uint8_t idApic; 6621 6625 int rc; 6622 bool fDeltaApplied = false;6623 6626 PSUPGLOBALINFOPAGE pGip; 6624 6627 … … 6626 6629 Assert(pDevExt); 6627 6630 Assert(pDevExt->pGip); 6628 6629 /*6630 * <Insert missing comment [it's not "Validate.", I think...]>6631 */6632 6631 pGip = pDevExt->pGip; 6632 6633 #ifdef SUPDRV_USE_TSC_DELTA_THREAD 6634 /* 6635 * If the TSC-delta thread is created, wait until it's done calculating 6636 * the TSC-deltas on the relevant online CPUs before we start the TSC refinement. 6637 */ 6638 if ( pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED 6639 && ASMAtomicReadS32(&pDevExt->rcTscDelta) == VERR_NOT_AVAILABLE) 6640 { 6641 rc = supdrvTscDeltaThreadWaitForOnlineCpus(pDevExt); 6642 if (rc == VERR_TIMEOUT) 6643 { 6644 SUPR0Printf("vboxdrv: Skipping refinement of TSC frequency as TSC-delta measurement timed out!\n"); 6645 return; 6646 } 6647 } 6648 #endif 6649 6650 /* 6651 * Record the TSC and NanoTS as the starting anchor point for refinement of the 6652 * TSC. We deliberately avoid using SUPReadTSC() here as we want to keep the 6653 * reading of the TSC and the NanoTS as close as possible. 6654 */ 6633 6655 u64NanoTS = RTTimeSystemNanoTS(); 6634 6656 while (RTTimeSystemNanoTS() == u64NanoTS) … … 6640 6662 ASMSetFlags(uFlags); 6641 6663 if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_PRACTICALLY_ZERO) 6642 supdrvTscDeltaApply(pGip, &pDevExt->u64TscAnchor, idApic, &fDeltaApplied); 6643 6644 #ifdef SUPDRV_USE_TSC_DELTA_THREAD 6645 /* 6646 * <Explain yourself> 6647 */ 6648 /** @todo r=bird: This is (and was) bogus on systems where we don't need to 6649 * apply any delta (not used on windows doesn't stick without comments). 6650 * What is the logic you want here exactly? */ 6651 if ( pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC 6652 && !fDeltaApplied) 6653 { 6654 rc = supdrvTscDeltaThreadWaitForOnlineCpus(pDevExt); 6655 if (rc == VERR_TIMEOUT) 6656 { 6657 SUPR0Printf("vboxdrv: Skipping refinement of TSC frequency as TSC-delta measurement timed out!\n"); 6658 return; 6659 } 6660 } 6661 #endif 6664 supdrvTscDeltaApply(pGip, &pDevExt->u64TscAnchor, idApic, NULL /* pfDeltaApplied */); 6662 6665 6663 6666 rc = RTTimerCreateEx(&pDevExt->pTscRefineTimer, 0 /* one-shot */, RTTIMER_FLAGS_CPU_ANY, supdrvRefineTscTimer, pDevExt); … … 6773 6776 if (RT_SUCCESS(rc)) 6774 6777 { 6778 #ifndef SUPDRV_USE_TSC_DELTA_THREAD 6775 6779 uint16_t iCpu; 6776 #ifndef SUPDRV_USE_TSC_DELTA_THREAD6777 6780 if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED) 6778 6781 { … … 6816 6819 } 6817 6820 if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC) 6818 rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, 0 /* fFlags */, 6821 rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, 0 /* fFlags */, 6819 6822 supdrvGipSyncAndInvariantTimer, pDevExt); 6820 6823 if (RT_SUCCESS(rc)) … … 6931 6934 6932 6935 /** 6933 * Timer callback function for the sync and invariant GIP modes.6934 * 6936 * Timer callback function for the sync and invariant GIP modes. 6937 * 6935 6938 * @param pTimer The timer. 6936 6939 * @param pvUser Opaque pointer to the device extension. … … 8320 8323 cMsWaitRetry = RT_MAX(pReq->u.In.cMsWaitRetry, 5); 8321 8324 8322 /* 8325 /* 8323 8326 * The request is a noop if the TSC delta isn't being used. 8324 8327 */ -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r54013 r54262 732 732 RTCPUSET TscDeltaObtainedCpuSet; 733 733 /** Whether the TSC-delta measurement was successful. */ 734 int 734 int32_t volatile rcTscDelta; 735 735 /** @} */ 736 736 #endif
Note:
See TracChangeset
for help on using the changeset viewer.