Skip to content

Commit

Permalink
PcAtChipsetPkg/HpetTimerDxe: Fix nested interrupt time accuracy
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4659

When HPET timer is used as the timer interrupt and nested
interrupts into the HPET timer interrupt handler occur, the
elapsed time passed into the DXE Core is sometime too large
and this causes the DXE Core internal system time to run too
fast. Fix the logic so the previous main counter value stored
in the module global variable mPreviousMainCounter is always
captured before the timer notification function is called.

Without this change, mPreviousMainCounter is updated after
the timer notification function is called and when nesting
occurs, it updates with the value from the first level of
nesting which is further back in time than the interrupt from
the deepest level of nesting.  This causes the next two timer
interrupts to compute a TimerPeriod that is twice the actual
time period since the last interrupt and this causes the DXE
Core internal time to run faster than expected.

Cc: Ray Ni <[email protected]>
Signed-off-by: Michael D Kinney <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
  • Loading branch information
mdkinney authored and mergify[bot] committed Jan 29, 2024
1 parent dc33394 commit a601362
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,18 @@ TimerInterruptHandler (
100000000
);

//
// Save main counter value before calling notification function
// that may enable interrupts and allow interrupt nesting.
//
mPreviousMainCounter = MainCounter;

//
// Call registered notification function passing in the time since the last
// interrupt in 100 ns units.
//
mTimerNotifyFunction (TimerPeriod);
return;
}

//
Expand Down

0 comments on commit a601362

Please sign in to comment.