summaryrefslogtreecommitdiffstats
path: root/PcAtChipsetPkg
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2024-01-25 23:31:44 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-01-29 19:17:00 +0000
commita6013625a3d7d949571fdc2cc4fc5905f37a0023 (patch)
tree0cdfee9c9971eaae0426cec16d2aeee034b0a629 /PcAtChipsetPkg
parentdc3339470166884197e9be5a6b3e7afe13104f1f (diff)
downloadedk2-a6013625a3d7d949571fdc2cc4fc5905f37a0023.tar.gz
edk2-a6013625a3d7d949571fdc2cc4fc5905f37a0023.tar.bz2
edk2-a6013625a3d7d949571fdc2cc4fc5905f37a0023.zip
PcAtChipsetPkg/HpetTimerDxe: Fix nested interrupt time accuracy
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 <ray.ni@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'PcAtChipsetPkg')
-rw-r--r--PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c b/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c
index 427572c2ff..e74777fbc6 100644
--- a/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c
+++ b/PcAtChipsetPkg/HpetTimerDxe/HpetTimer.c
@@ -388,10 +388,17 @@ TimerInterruptHandler (
);
//
+ // 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;
}
//