VirtualBox

Changeset 37237 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 27, 2011 2:57:54 PM (14 years ago)
Author:
vboxsync
Message:

DevACPI: attempt to make the ACPI timer SMP-safe

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r35773 r37237  
    203203    /** Number of logical CPUs in guest */
    204204    uint16_t            cCpus;
    205     int64_t             pm_timer_initial;
     205    uint64_t            u64PmTimerInitial;
     206    uint64_t            u64PmTimerLastSeen;
    206207    PTMTIMERR3          tsR3;
    207208    PTMTIMERR0          tsR0;
     
    19191920    {
    19201921        ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *);
    1921         int64_t now = TMTimerGet(s->CTX_SUFF(ts));
    1922         int64_t elapsed = now - s->pm_timer_initial;
    1923 
    1924         *pu32 = ASMMultU64ByU32DivByU32(elapsed, PM_TMR_FREQ, TMTimerGetFreq(s->CTX_SUFF(ts)));
     1922        uint64_t u64Now = TMTimerGet(s->CTX_SUFF(ts));
     1923        uint64_t u64Seen;
     1924        do
     1925        {
     1926            u64Seen = ASMAtomicReadU64(&s->u64PmTimerLastSeen);
     1927            if (u64Now < s->u64PmTimerLastSeen)
     1928                u64Now = s->u64PmTimerLastSeen + 1;
     1929        } while (!ASMAtomicCmpXchgU64(&s->u64PmTimerLastSeen, u64Now, u64Seen));
     1930
     1931        uint64_t u64Elapsed = u64Now - s->u64PmTimerInitial;
     1932        *pu32 = ASMMultU64ByU32DivByU32(u64Elapsed, PM_TMR_FREQ, TMTimerGetFreq(s->CTX_SUFF(ts)));
    19251933        Log(("acpi: acpiPMTmrRead -> %#x\n", *pu32));
    19261934        return VINF_SUCCESS;
     
    21212129    SSMFIELD_ENTRY(ACPIState, pm1a_sts),
    21222130    SSMFIELD_ENTRY(ACPIState, pm1a_ctl),
    2123     SSMFIELD_ENTRY(ACPIState, pm_timer_initial),
     2131    SSMFIELD_ENTRY(ACPIState, u64PmTimerInitial),
    21242132    SSMFIELD_ENTRY(ACPIState, gpe0_en),
    21252133    SSMFIELD_ENTRY(ACPIState, gpe0_sts),
     
    21412149    SSMFIELD_ENTRY(ACPIState, pm1a_sts),
    21422150    SSMFIELD_ENTRY(ACPIState, pm1a_ctl),
    2143     SSMFIELD_ENTRY(ACPIState, pm_timer_initial),
     2151    SSMFIELD_ENTRY(ACPIState, u64PmTimerInitial),
    21442152    SSMFIELD_ENTRY(ACPIState, gpe0_en),
    21452153    SSMFIELD_ENTRY(ACPIState, gpe0_sts),
     
    21602168    SSMFIELD_ENTRY(ACPIState, pm1a_sts),
    21612169    SSMFIELD_ENTRY(ACPIState, pm1a_ctl),
    2162     SSMFIELD_ENTRY(ACPIState, pm_timer_initial),
     2170    SSMFIELD_ENTRY(ACPIState, u64PmTimerInitial),
    21632171    SSMFIELD_ENTRY(ACPIState, gpe0_en),
    21642172    SSMFIELD_ENTRY(ACPIState, gpe0_sts),
     
    25792587    s->pm1a_sts          = 0;
    25802588    s->pm1a_ctl          = 0;
    2581     s->pm_timer_initial = TMTimerGet(s->CTX_SUFF(ts));
     2589    s->u64PmTimerInitial = TMTimerGet(s->CTX_SUFF(ts));
    25822590    acpiPMTimerReset(s);
    25832591    s->uBatteryIndex     = 0;
     
    28892897    s->tsR0 = TMTimerR0Ptr(s->tsR3);
    28902898    s->tsRC = TMTimerRCPtr(s->tsR3);
    2891     s->pm_timer_initial = TMTimerGet(s->tsR3);
     2899    s->u64PmTimerInitial = TMTimerGet(s->tsR3);
    28922900    acpiPMTimerReset(s);
    28932901
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r36878 r37237  
    480480    GEN_CHECK_OFF(ACPIState, pm1a_sts);
    481481    GEN_CHECK_OFF(ACPIState, pm1a_ctl);
    482     GEN_CHECK_OFF(ACPIState, pm_timer_initial);
     482    GEN_CHECK_OFF(ACPIState, u64PmTimerInitial);
    483483    GEN_CHECK_OFF(ACPIState, tsR3);
    484484    GEN_CHECK_OFF(ACPIState, tsR0);
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