public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UefiCpuPkg: CpuTimerDxeRiscV64: Fix timer event not working correctly
@ 2023-06-28  1:15 Tuan Phan
  2023-06-28 14:43 ` Sunil V L
  0 siblings, 1 reply; 3+ messages in thread
From: Tuan Phan @ 2023-06-28  1:15 UTC (permalink / raw)
  To: devel; +Cc: sunilvl, andrei.warkentin, Tuan Phan

The timer notify function should be called with timer period, not the
value read from timer register.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
---
 UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
index 358057e7c6a4..30e48061cd06 100644
--- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
+++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
@@ -9,6 +9,7 @@
 
 #include <Library/BaseLib.h>
 #include <Library/BaseRiscVSbiLib.h>
+#include <Library/UefiLib.h>
 #include "Timer.h"
 
 //
@@ -71,7 +72,12 @@ TimerInterruptHandler (
     // time to increment slower. So when we take an interrupt,
     // account for the actual time passed.
     //
-    mTimerNotifyFunction (PeriodStart - mLastPeriodStart);
+    mTimerNotifyFunction (
+      DivU64x32 (
+        EFI_TIMER_PERIOD_SECONDS (PeriodStart - mLastPeriodStart),
+        PcdGet64 (PcdCpuCoreCrystalClockFrequency)
+        )
+      );
   }
 
   if (mTimerPeriod == 0) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-28 21:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28  1:15 [PATCH] UefiCpuPkg: CpuTimerDxeRiscV64: Fix timer event not working correctly Tuan Phan
2023-06-28 14:43 ` Sunil V L
2023-06-28 21:06   ` Tuan Phan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox