VirtualBox

Ignore:
Timestamp:
Apr 26, 2007 10:13:38 PM (18 years ago)
Author:
vboxsync
Message:

When in async mode we must update the aCPUs data everywhere since we don't know which CPU the operation will be resumed on.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r2242 r2373  
    14041404    pGip    = pDevExt->pGip;
    14051405    ulNow   = jiffies;
    1406     ulDiff  = ulNow - pDevExt->ulLastJiffies;
    1407 
    1408     pDevExt->ulLastJiffies = ulNow;
     1406
     1407#ifdef CONFIG_SMP
     1408    if (pGip && pGip->u32Mode == SUPGIPMODE_ASYNC_TSC)
     1409    {
     1410        uint8_t iCPU = ASMGetApicId();
     1411        ulDiff = ulNow - pDevExt->aCPUs[iCPU].ulLastJiffies;
     1412        pDevExt->aCPUs[iCPU].ulLastJiffies = ulNow;
    14091413#ifdef TICK_NSEC
    1410     u64Monotime = pDevExt->u64LastMonotime + ulDiff * TICK_NSEC;
     1414        u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * TICK_NSEC;
    14111415#else
    1412     u64Monotime = pDevExt->u64LastMonotime + ulDiff * (1000000 / HZ);
    1413 #endif
    1414     ASMAtomicXchgU64(&pDevExt->u64LastMonotime, u64Monotime);
     1416        u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * (1000000 / HZ);
     1417#endif
     1418        pDevExt->aCPUs[iCPU].u64LastMonotime = u64Monotime;
     1419    }
     1420    else
     1421#endif /* CONFIG_SMP */
     1422    {
     1423        ulDiff = ulNow - pDevExt->ulLastJiffies;
     1424        pDevExt->ulLastJiffies = ulNow;
     1425#ifdef TICK_NSEC
     1426        u64Monotime = pDevExt->u64LastMonotime + ulDiff * TICK_NSEC;
     1427#else
     1428        u64Monotime = pDevExt->u64LastMonotime + ulDiff * (1000000 / HZ);
     1429#endif
     1430        pDevExt->u64LastMonotime = u64Monotime;
     1431    }
    14151432    if (RT_LIKELY(pGip))
    14161433        supdrvGipUpdate(pDevExt->pGip, u64Monotime);
    1417     mod_timer(&g_GipTimer, jiffies + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES));
     1434    if (RT_LIKELY(!pDevExt->fGIPSuspended))
     1435        mod_timer(&g_GipTimer, ulNow + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES));
    14181436
    14191437    local_irq_restore(SavedFlags);
     
    14251443 * Timer callback function for the other CPUs.
    14261444 *
    1427  * @param   iLnxCPU     The APIC ID of this timer.
    1428  */
    1429 static void VBoxSupGipTimerPerCpu(unsigned long iLnxCPU)
     1445 * @param   iTimerCPU     The APIC ID of this timer.
     1446 */
     1447static void VBoxSupGipTimerPerCpu(unsigned long iTimerCPU)
    14301448{
    14311449    PSUPDRVDEVEXT       pDevExt;
     
    14431461    if (RT_LIKELY(iCPU < RT_ELEMENTS(pGip->aCPUs)))
    14441462    {
    1445         if (RT_LIKELY(iCPU == iLnxCPU))
     1463        if (RT_LIKELY(iTimerCPU == iCPU))
    14461464        {
    14471465            unsigned long   ulNow  = jiffies;
    1448             unsigned long   ulDiff = ulNow - pDevExt->aCPUs[iLnxCPU].ulLastJiffies;
    1449 
    1450             pDevExt->aCPUs[iLnxCPU].ulLastJiffies = ulNow;
     1466            unsigned long   ulDiff = ulNow - pDevExt->aCPUs[iCPU].ulLastJiffies;
     1467            pDevExt->aCPUs[iCPU].ulLastJiffies = ulNow;
    14511468#ifdef TICK_NSEC
    14521469            u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * TICK_NSEC;
     
    14541471            u64Monotime = pDevExt->aCPUs[iCPU].u64LastMonotime + ulDiff * (1000000 / HZ);
    14551472#endif
    1456             ASMAtomicXchgU64(&pDevExt->aCPUs[iCPU].u64LastMonotime, u64Monotime);
     1473            pDevExt->aCPUs[iCPU].u64LastMonotime = u64Monotime;
    14571474            if (RT_LIKELY(pGip))
    14581475                supdrvGipUpdatePerCpu(pGip, u64Monotime, iCPU);
    1459             mod_timer(&pDevExt->aCPUs[iCPU].Timer, jiffies + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES));
     1476            if (RT_LIKELY(!pDevExt->fGIPSuspended))
     1477                mod_timer(&pDevExt->aCPUs[iCPU].Timer, ulNow + (HZ <= 1000 ? 0 : ONE_MSEC_IN_JIFFIES));
    14601478        }
    14611479        else
    1462             printk("vboxdrv: error: GIP CPU update timer executing on the wrong CPU: apicid=%d != timer-apicid=%ld (cpuid=%d != timer-cpuid=%d)\n",
    1463                    iCPU, iLnxCPU, smp_processor_id(), pDevExt->aCPUs[iLnxCPU].iSmpProcessorId);
     1480            printk("vboxdrv: error: GIP CPU update timer executing on the wrong CPU: apicid=%d != timer-apicid=%ld (cpuid=%d !=? timer-cpuid=%d)\n",
     1481                   iCPU, iTimerCPU, smp_processor_id(), pDevExt->aCPUs[iTimerCPU].iSmpProcessorId);
    14641482    }
    14651483    else
     
    15771595{
    15781596    dprintf2(("supdrvOSGipResume:\n"));
     1597    ASMAtomicXchgU8(&pDevExt->fGIPSuspended, false);
    15791598#ifdef CONFIG_SMP
    15801599    if (pDevExt->pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
     
    16281647#endif
    16291648    dprintf2(("supdrvOSGipSuspend:\n"));
     1649    ASMAtomicXchgU8(&pDevExt->fGIPSuspended, true);
    16301650
    16311651    if (timer_pending(&g_GipTimer))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette