[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240829033904.477200-3-nick.hu@sifive.com>
Date: Thu, 29 Aug 2024 11:39:00 +0800
From: Nick Hu <nick.hu@...ive.com>
To: greentime.hu@...ive.com,
zong.li@...ive.com,
"Rafael J. Wysocki" <rafael@...nel.org>,
Pavel Machek <pavel@....cz>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andrew Jones <ajones@...tanamicro.com>,
Conor Dooley <conor.dooley@...rochip.com>,
Samuel Holland <samuel.holland@...ive.com>,
Nick Hu <nick.hu@...ive.com>,
Sunil V L <sunilvl@...tanamicro.com>,
linux-pm@...r.kernel.org,
linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] time-riscv: Stop stimecmp when cpu hotplug
Stop the stimecmp when the cpu is going to be off otherwise the timer
interrupt may pending while performing power down operation.
Signed-off-by: Nick Hu <nick.hu@...ive.com>
---
drivers/clocksource/timer-riscv.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index 48ce50c5f5e6..9a6acaa8dfb0 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -32,15 +32,19 @@
static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available);
static bool riscv_timer_cannot_wake_cpu;
+static void riscv_clock_stop_stimecmp(void)
+{
+ csr_write(CSR_STIMECMP, ULONG_MAX);
+ if (IS_ENABLED(CONFIG_32BIT))
+ csr_write(CSR_STIMECMPH, ULONG_MAX);
+}
+
static void riscv_clock_event_stop(void)
{
- if (static_branch_likely(&riscv_sstc_available)) {
- csr_write(CSR_STIMECMP, ULONG_MAX);
- if (IS_ENABLED(CONFIG_32BIT))
- csr_write(CSR_STIMECMPH, ULONG_MAX);
- } else {
+ if (static_branch_likely(&riscv_sstc_available))
+ riscv_clock_stop_stimecmp();
+ else
sbi_set_timer(U64_MAX);
- }
}
static int riscv_clock_next_event(unsigned long delta,
@@ -126,7 +130,11 @@ static int riscv_timer_starting_cpu(unsigned int cpu)
static int riscv_timer_dying_cpu(unsigned int cpu)
{
- disable_percpu_irq(riscv_clock_event_irq);
+ if (static_branch_likely(&riscv_sstc_available))
+ riscv_clock_stop_stimecmp();
+ else
+ disable_percpu_irq(riscv_clock_event_irq);
+
return 0;
}
--
2.34.1
Powered by blists - more mailing lists