From: Nick Hu <nick.hu@sifive.com>
To: greentime.hu@sifive.com, zong.li@sifive.com,
"Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@ucw.cz>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Jones <ajones@ventanamicro.com>,
Conor Dooley <conor.dooley@microchip.com>,
Samuel Holland <samuel.holland@sifive.com>,
Nick Hu <nick.hu@sifive.com>,
Sunil V L <sunilvl@ventanamicro.com>,
linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] time-riscv: Stop stimecmp when cpu hotplug
Date: Thu, 29 Aug 2024 11:39:00 +0800 [thread overview]
Message-ID: <20240829033904.477200-3-nick.hu@sifive.com> (raw)
In-Reply-To: <20240829033904.477200-1-nick.hu@sifive.com>
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@sifive.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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2024-08-29 3:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 3:38 [PATCH 0/2] Support SSTC while PM operations Nick Hu
2024-08-29 3:38 ` [PATCH 1/2] riscv: Add stimecmp save and restore Nick Hu
2024-08-29 5:18 ` Anup Patel
2024-08-29 6:16 ` Nick Hu
2024-08-29 7:59 ` Andrew Jones
2024-08-30 5:53 ` Nick Hu
2024-08-29 3:39 ` Nick Hu [this message]
2024-08-29 5:18 ` [PATCH 2/2] time-riscv: Stop stimecmp when cpu hotplug Anup Patel
2024-08-29 6:23 ` Nick Hu
2024-08-29 6:49 ` Anup Patel
2024-08-30 5:56 ` Nick Hu
2024-08-29 13:43 ` Thomas Gleixner
2024-08-30 5:56 ` Nick Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240829033904.477200-3-nick.hu@sifive.com \
--to=nick.hu@sifive.com \
--cc=ajones@ventanamicro.com \
--cc=aou@eecs.berkeley.edu \
--cc=conor.dooley@microchip.com \
--cc=daniel.lezcano@linaro.org \
--cc=greentime.hu@sifive.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=sunilvl@ventanamicro.com \
--cc=tglx@linutronix.de \
--cc=zong.li@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox