PcAtChipsetPkg/HpetTimerDxe: Fix race condition in SetTimerPeriod()
[mirror_edk2.git] / PcAtChipsetPkg / HpetTimerDxe / HpetTimer.c
index 0ed8743..c62c3a9 100644 (file)
@@ -492,11 +492,17 @@ TimerDriverSetTimerPeriod (
   IN UINT64                   TimerPeriod\r
   )\r
 {\r
+  EFI_TPL                        Tpl;\r
   UINT64                         MainCounter;\r
   UINT64                         Delta;\r
   UINT64                         CurrentComparator;\r
   HPET_TIMER_MSI_ROUTE_REGISTER  HpetTimerMsiRoute;\r
-  \r
+\r
+  //\r
+  // Disable interrupts\r
+  //\r
+  Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
   //\r
   // Disable HPET timer when adjusting the timer period\r
   //\r
@@ -616,7 +622,12 @@ TimerDriverSetTimerPeriod (
   // is disabled.\r
   //\r
   HpetEnable (TRUE);\r
-  \r
+\r
+  //\r
+  // Restore interrupts\r
+  //\r
+  gBS->RestoreTPL (Tpl);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r