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

[PATCH 11/19] xen/arm: Suspend/resume timer interrupt generation


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Fri, 7 Oct 2022 10:32:49 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; 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=qxsl5gDF3/jSVy2BBSafg6Ww5MOd3+YkfDQ+9kQ0VuY=; b=XCNTFwrOA20JWVCexD6aEQgubr4JQ6Vq1N7SM9W9wR/LUNQmuX/pucmr9bFx9lgWjypoMHTVmm5uSBMLNAAdNtVnBgSTZW/iQHmiYf/6g3CbBeydNZzOVqbDSV6SDfzuQA7Mc1CZuFg6tcgc1AsmsvB6mOgdhFDqhNp1YXR5BrWvUtGbTfz0hQO5QN4GGZT2xDQh6ukZYJyoZq/IElFIAQUw/XQsnrcf1qHDnjK7km0rtQv4IwpYdz8aksShAN9GNHxwtTcWQUtkpcmXxRXgEPb9lsKuQBN6YXyav4eL2UPJGyC2+wPpJgjBHZatGrRxyOA0FouvkBZoUz9tn8A3DA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NBzf5NC2lZI92DtwkCsZInhkjWY45tjbIfqEZ6I4vquP8pcO3rXf9cNS6YahHLjVWECTeO2n0Gg4tY8fQqoEa6M+Z0LmVJgizIBz+H3TYKwVzsNt6/BtFGXWR36DXdyM4FM2X4/NyGa9B7R30MCvQE+ImO8PrMHmPAuhxkU9mzigg7Olq+CAWq/D9Ogywo2rFrvKzDTT+rw7f+5K/wWmhpeaWn4MM40pbXHFR16wCDl9JTzeSkE2EJSWB/gqIPj3oL7/F8BZSGwOBzAub8nYKUpSshM5qzTdhqf7CLWbgnnRy5mYsGnIZzXAL7vp6z0Vha1PCAewulIjw3CMJuOPMg==
  • Cc: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Saeed Nowshadi <saeed.nowshadi@xxxxxxxxxx>
  • Delivery-date: Fri, 07 Oct 2022 10:33:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY2jgl07ov6FowcUeH35VPDOse0g==
  • Thread-topic: [PATCH 11/19] xen/arm: Suspend/resume timer interrupt generation

From: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>

Timer interrupts have to be disabled while the system is in suspend.
Otherwise, a timer interrupt would fire and wake-up the system.
Suspending the timer interrupts consists of disabling physical EL1
and EL2 timers. The resume consists only of raising timer softirq,
which will trigger the generic timer code to reprogram the EL2 timer
as needed. Enabling of EL1 physical timer will be triggered by an
entity which uses it.

Signed-off-by: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx>
Signed-off-by: Saeed Nowshadi <saeed.nowshadi@xxxxxxxxxx>
---
 xen/arch/arm/suspend.c     |  4 ++++
 xen/arch/arm/time.c        | 22 ++++++++++++++++++++++
 xen/include/asm-arm/time.h |  3 +++
 3 files changed, 29 insertions(+)

diff --git a/xen/arch/arm/suspend.c b/xen/arch/arm/suspend.c
index b94a6df86d..05c43ce502 100644
--- a/xen/arch/arm/suspend.c
+++ b/xen/arch/arm/suspend.c
@@ -151,6 +151,8 @@ static long system_suspend(void *data)
         goto resume_nonboot_cpus;
     }
 
+    time_suspend();
+
     local_irq_save(flags);
     status = gic_suspend();
     if ( status )
@@ -166,6 +168,8 @@ static long system_suspend(void *data)
 resume_irqs:
     local_irq_restore(flags);
 
+    time_resume();
+
 resume_nonboot_cpus:
     rcu_barrier();
     enable_nonboot_cpus();
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index dec53b5f7d..ca54bcfe68 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -363,6 +363,28 @@ void domain_set_time_offset(struct domain *d, int64_t 
time_offset_seconds)
     /* XXX update guest visible wallclock time */
 }
 
+void time_suspend(void)
+{
+    /* Disable physical EL1 timer */
+    WRITE_SYSREG(0, CNTP_CTL_EL0);
+
+    /* Disable hypervisor's timer */
+    WRITE_SYSREG(0, CNTHP_CTL_EL2);
+    isb();
+}
+
+void time_resume(void)
+{
+    /*
+     * Raising timer softirq will trigger generic timer code to reprogram_timer
+     * with the correct timeout value (which is not known here). There is no
+     * need to do anything else in order to recover the time keeping from power
+     * down, because the system counter is not affected by the power down (it
+     * resides out of the ARM's cluster in an always-on part of the SoC).
+     */
+    raise_softirq(TIMER_SOFTIRQ);
+}
+
 static int cpu_time_callback(struct notifier_block *nfb,
                              unsigned long action,
                              void *hcpu)
diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h
index 4b401c1110..ded93b490a 100644
--- a/xen/include/asm-arm/time.h
+++ b/xen/include/asm-arm/time.h
@@ -107,6 +107,9 @@ void preinit_xen_time(void);
 
 void force_update_vcpu_system_time(struct vcpu *v);
 
+void time_suspend(void);
+void time_resume(void);
+
 #endif /* __ARM_TIME_H__ */
 /*
  * Local variables:
-- 
2.37.1



 


Rackspace

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