Changeset 1869 in vbox for trunk/src/VBox/HostDrivers/Support/linux
- Timestamp:
- Apr 2, 2007 11:12:09 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r1850 r1869 1321 1321 for (i = 0; i < RT_ELEMENTS(pDevExt->aCPUs); i++) 1322 1322 { 1323 pDevExt->aCPUs[i].u64LastMonotime = pDevExt->u64LastMonotime; 1324 pDevExt->aCPUs[i].ulLastJiffies = pDevExt->ulLastJiffies; 1325 pDevExt->aCPUs[i].iSmpProcessorId = -512; 1323 1326 init_timer(&pDevExt->aCPUs[i].Timer); 1324 pDevExt->aCPUs[i].Timer.data = (unsigned long)pDevExt;1325 pDevExt->aCPUs[i].Timer.function = VBoxSupGipTimerPerCpu;1326 pDevExt->aCPUs[i].Timer.expires = jiffies;1327 pDevExt->aCPUs[i].Timer.data = i; 1328 pDevExt->aCPUs[i].Timer.function = VBoxSupGipTimerPerCpu; 1329 pDevExt->aCPUs[i].Timer.expires = jiffies; 1327 1330 } 1328 1331 #endif … … 1390 1393 static void VBoxSupGipTimer(unsigned long ulUser) 1391 1394 { 1392 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)ulUser; 1393 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 1394 unsigned long ulNow = jiffies; 1395 unsigned long ulDiff = ulNow - pDevExt->ulLastJiffies; 1396 uint64_t u64Monotime; 1395 PSUPDRVDEVEXT pDevExt; 1396 PSUPGLOBALINFOPAGE pGip; 1397 unsigned long ulNow; 1398 unsigned long ulDiff; 1399 uint64_t u64Monotime; 1400 unsigned long SavedFlags; 1401 1402 local_irq_save(SavedFlags); 1403 1404 pDevExt = (PSUPDRVDEVEXT)ulUser; 1405 pGip = pDevExt->pGip; 1406 ulNow = jiffies; 1407 ulDiff = ulNow - pDevExt->ulLastJiffies; 1408 1397 1409 pDevExt->ulLastJiffies = ulNow; 1398 1410 #ifdef TICK_NSEC … … 1405 1417 supdrvGipUpdate(pDevExt->pGip, u64Monotime); 1406 1418 mod_timer(&g_GipTimer, jiffies + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES)); 1419 1420 local_irq_restore(SavedFlags); 1407 1421 } 1408 1422 … … 1412 1426 * Timer callback function for the other CPUs. 1413 1427 * 1414 * @param ulUser The device extension pointer. 1415 */ 1416 static void VBoxSupGipTimerPerCpu(unsigned long ulUser) 1417 { 1418 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)ulUser; 1419 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 1420 unsigned long ulNow = jiffies; 1421 unsigned long ulDiff = ulNow - pDevExt->ulLastJiffies; 1428 * @param iLnxCPU The APIC ID of this timer. 1429 */ 1430 static void VBoxSupGipTimerPerCpu(unsigned long iLnxCPU) 1431 { 1432 PSUPDRVDEVEXT pDevExt; 1433 PSUPGLOBALINFOPAGE pGip; 1434 uint8_t iCPU; 1422 1435 uint64_t u64Monotime; 1423 uint8_t iCPU = ASMGetApicId(); 1424 1425 if (RT_UNLIKELY(iCPU >= RT_ELEMENTS(pGip->aCPUs))) 1426 { 1427 printk("vboxdrv: error: apicid=%d max=%d cpuid=%d\n", 1436 unsigned long SavedFlags; 1437 1438 local_irq_save(SavedFlags); 1439 1440 pDevExt = &g_DevExt; 1441 pGip = pDevExt->pGip; 1442 iCPU = ASMGetApicId(); 1443 1444 if (RT_LIKELY(iCPU < RT_ELEMENTS(pGip->aCPUs))) 1445 { 1446 if (RT_LIKELY(iCPU == iLnxCPU)) 1447 { 1448 unsigned long ulNow = jiffies; 1449 unsigned long ulDiff = ulNow - pDevExt->aCPUs[iLnxCPU].ulLastJiffies; 1450 1451 pDevExt->aCPUs[iLnxCPU].ulLastJiffies = ulNow; 1452 #ifdef TICK_NSEC 1453 u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * TICK_NSEC; 1454 #else 1455 u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * (1000000 / HZ); 1456 #endif 1457 ASMAtomicXchgU64(&pDevExt->aCPUs[iCPU].u64LastMonotime, u64Monotime); 1458 if (RT_LIKELY(pGip)) 1459 supdrvGipUpdatePerCpu(pGip, u64Monotime, iCPU); 1460 mod_timer(&pDevExt->aCPUs[iCPU].Timer, jiffies + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES)); 1461 } 1462 else 1463 printk("vboxdrv: error: GIP CPU update timer executing on the wrong CPU: apicid=%d != timer-apicid=%ld (cpuid=%d != timer-cpuid=%d)\n", 1464 iCPU, iLnxCPU, smp_processor_id(), pDevExt->aCPUs[iLnxCPU].iSmpProcessorId); 1465 } 1466 else 1467 printk("vboxdrv: error: APIC ID is bogus (GIP CPU update): apicid=%d max=%d cpuid=%d\n", 1428 1468 iCPU, RT_ELEMENTS(pGip->aCPUs), smp_processor_id()); 1429 return; 1430 } 1431 1432 pDevExt->aCPUs[iCPU].ulLastJiffies = ulNow; 1433 #ifdef TICK_NSEC 1434 u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * TICK_NSEC; 1435 #else 1436 u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * (1000000 / HZ); 1437 #endif 1438 ASMAtomicXchgU64(&pDevExt->aCPUs[iCPU].u64LastMonotime, u64Monotime); 1439 if (RT_LIKELY(pGip)) 1440 supdrvGipUpdatePerCpu(pGip, pDevExt->aCPUs[iCPU].u64LastMonotime, iCPU); 1441 mod_timer(&pDevExt->aCPUs[iCPU].Timer, jiffies + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES)); 1469 1470 local_irq_restore(SavedFlags); 1442 1471 } 1443 1472 #endif /* CONFIG_SMP */ … … 1576 1605 uint8_t iCPU = ASMGetApicId(); 1577 1606 1578 1579 1607 if (RT_UNLIKELY(iCPU >= RT_ELEMENTS(pDevExt->pGip->aCPUs))) 1580 1608 { … … 1584 1612 } 1585 1613 1614 pDevExt->aCPUs[iCPU].iSmpProcessorId = smp_processor_id(); 1586 1615 mod_timer(&pDevExt->aCPUs[iCPU].Timer, jiffies); 1587 1616 }
Note:
See TracChangeset
for help on using the changeset viewer.