public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPkg/TimerDxe: Always perform an EOI, even for spurious interrupts
@ 2018-03-06 13:24 Ard Biesheuvel
  2018-03-06 14:25 ` Laszlo Ersek
  0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2018-03-06 13:24 UTC (permalink / raw)
  To: edk2-devel; +Cc: leif.lindholm, marc.zyngier

From: Marc Zyngier <marc.zyngier@arm.com>

The generic timer driver only EOIs the timer interrupt if
the ISTATUS bit is set. This is completely fine if you pretend
that spurious interrupts do not exist. But as a matter of fact,
they do, and the first one will leave the interrupt activated
at the GIC level, making sure that no other interrupt can make
it anymore.

Making sure that each interrupt Ack is paired with an EOI is the
way to go. Oh, and enabling the interrupt each time it is taken
is completely pointless. We entered this function for a good
reason...

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPkg/Drivers/TimerDxe/TimerDxe.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
index 2416c90f5545..33d7c922221f 100644
--- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c
+++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
@@ -306,12 +306,13 @@ TimerInterruptHandler (
   //
   OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
 
+  // Signal end of interrupt early to help avoid losing subsequent ticks
+  // from long duration handlers
+  gInterrupt->EndOfInterrupt (gInterrupt, Source);
+
   // Check if the timer interrupt is active
   if ((ArmGenericTimerGetTimerCtrlReg () ) & ARM_ARCH_TIMER_ISTATUS) {
 
-    // Signal end of interrupt early to help avoid losing subsequent ticks from long duration handlers
-    gInterrupt->EndOfInterrupt (gInterrupt, Source);
-
     if (mTimerNotifyFunction) {
       mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod);
     }
@@ -339,9 +340,6 @@ TimerInterruptHandler (
     ArmGenericTimerEnableTimer ();
   }
 
-  // Enable timer interrupts
-  gInterrupt->EnableInterruptSource (gInterrupt, Source);
-
   gBS->RestoreTPL (OriginalTPL);
 }
 
-- 
2.11.0



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

end of thread, other threads:[~2018-03-06 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-06 13:24 [PATCH] ArmPkg/TimerDxe: Always perform an EOI, even for spurious interrupts Ard Biesheuvel
2018-03-06 14:25 ` Laszlo Ersek
2018-03-06 14:39   ` Ard Biesheuvel
2018-03-06 14:48   ` Marc Zyngier

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