[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN v1] xen: arm: Check if timer is enabled for timer irq


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Wed, 10 Aug 2022 11:58:22 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rGpVah3n59CPxVuVNYgeIaw/1zZRjH3TajyXnIc0KM8=; b=KKi/blT4LDijAz3NAKalpfomNMpnbiTdkmBDqWVfoH7wNCjOiSY515FQSNhFojKd8l9jAQjIHNr3inPco8rq2fNvyS7z2tTGgmpI6IJc+J8RxrzoBAzcbVNj0+OeUUPAeG76DTbkOcIK11k63ivHPp4vzZeN+jos65ncCPq7zPhyE6MxaKmD2D/4c2KSphtZqCX1oK3dbmNYu3eOSk1rFexngg1Y5vNqPg63y37KjLs8+d7TTJQ8gTuWAR0cQyMrEeCZcBd7KWsXUhtI+Yyo8zwHm3HrjYtqDtWb1laQF3f/FPf1L6mwGJhkvqC+LCIH1jLq3RYVju5d3sJuj1afDQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQKhm4i0AMca9aBYYr4+37laaBZdfflxqJExrV3K1xCjI8CQtmLVKQmIwvb/Ng4XRphL0mMyE3uhFgV5V/Oftxk6vA20I05MHftHMXaNcIk39PZDeIA0lGllkmSFmDQq1p8JyVlr1o6/MIqkGwwf4Pr9GR3/oBy7vtwEVIs6lRIu0QwDuEv2oeML6A0MjY+eskTZbnC2LVVNxZO2VfOOFRhI1UqJ03b22MbHlg2dM3hxZiUOnx3fxcBnWzAtGMssSmEzZq1VcBiyDbQL5BsM4pMgESAQ+kG+DQAlmlSN1bbGhQ1NlRcvopcLG46k/QawnOufm8AJmr4pfqEa+1TVqA==
  • Cc: <sstabellini@xxxxxxxxxx>, <stefanos@xxxxxxx>, <julien@xxxxxxx>, <Volodymyr_Babchuk@xxxxxxxx>, <bertrand.marquis@xxxxxxx>, Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Delivery-date: Wed, 10 Aug 2022 10:59:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Refer "Arm Architecture Registers DDI 0595", AArch32 system registers,
CNTHP_CTL :- "When the value of the ENABLE bit is 1, ISTATUS indicates
whether the timer condition is met."

Also similar description applies to CNTP_CTL as well.

One should always check that the timer is enabled and status is set, to
determine if the timer interrupt has been generated.

Signed-off-by: Ayan Kumar Halder <ayankuma@xxxxxxx>
---
 xen/arch/arm/time.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index dec53b5f7d..f220586c52 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -222,8 +222,13 @@ int reprogram_timer(s_time_t timeout)
 /* Handle the firing timer */
 static void timer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
 {
-    if ( irq == (timer_irq[TIMER_HYP_PPI]) &&
-         READ_SYSREG(CNTHP_CTL_EL2) & CNTx_CTL_PENDING )
+    uint8_t timer_en_mask = (CNTx_CTL_PENDING | CNTx_CTL_ENABLE);
+    bool timer_cond_el2 = (READ_SYSREG(CNTHP_CTL_EL2) & timer_en_mask) ==
+        timer_en_mask ? true : false;
+    bool timer_cond_el0 = (READ_SYSREG(CNTP_CTL_EL0) & timer_en_mask) ==
+        timer_en_mask ? true : false;
+
+    if ( irq == (timer_irq[TIMER_HYP_PPI]) && timer_cond_el2 )
     {
         perfc_incr(hyp_timer_irqs);
         /* Signal the generic timer code to do its work */
@@ -232,8 +237,7 @@ static void timer_interrupt(int irq, void *dev_id, struct 
cpu_user_regs *regs)
         WRITE_SYSREG(0, CNTHP_CTL_EL2);
     }
 
-    if ( irq == (timer_irq[TIMER_PHYS_NONSECURE_PPI]) &&
-         READ_SYSREG(CNTP_CTL_EL0) & CNTx_CTL_PENDING )
+    if ( irq == (timer_irq[TIMER_PHYS_NONSECURE_PPI]) && timer_cond_el0 )
     {
         perfc_incr(phys_timer_irqs);
         /* Signal the generic timer code to do its work */
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.