[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231120024652.3191881-1-maobibo@loongson.cn>
Date: Mon, 20 Nov 2023 10:46:52 +0800
From: Bibo Mao <maobibo@...ngson.cn>
To: Huacai Chen <chenhuacai@...nel.org>,
WANG Xuerui <kernel@...0n.name>
Cc: Peter Zijlstra <peterz@...radead.org>, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org, WANG Xuerui <git@...0n.name>
Subject: [PATCH v2] LoongArch: Implement constant timer shutdown interface
When cpu is hot-unplugged,, it is put in idle state and function
arch_cpu_idle_dead is called. Timer interrupt for this processor should be
disabled, else there will be pending timer interrupt for the plug-out cpu,
so that vcpu is prevented from giving up scheduling when system is running
in vm mode.
This patch implements the timer shutdown interface so that the timer will
be properly disabled when a CPU is hot-unplugged.
Signed-off-by: Bibo Mao <maobibo@...ngson.cn>
Reviewed-by: WANG Xuerui <git@...0n.name>
---
Changes in v2:
1. Remove function constant_set_state_oneshot_stopped and add detailed
implementation in constant_set_state_shutdown.
2. Modify patch description and make it easier to understand.
---
arch/loongarch/kernel/time.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/arch/loongarch/kernel/time.c b/arch/loongarch/kernel/time.c
index 3064af94db9c..6a1734473aea 100644
--- a/arch/loongarch/kernel/time.c
+++ b/arch/loongarch/kernel/time.c
@@ -58,21 +58,6 @@ static int constant_set_state_oneshot(struct clock_event_device *evt)
return 0;
}
-static int constant_set_state_oneshot_stopped(struct clock_event_device *evt)
-{
- unsigned long timer_config;
-
- raw_spin_lock(&state_lock);
-
- timer_config = csr_read64(LOONGARCH_CSR_TCFG);
- timer_config &= ~CSR_TCFG_EN;
- csr_write64(timer_config, LOONGARCH_CSR_TCFG);
-
- raw_spin_unlock(&state_lock);
-
- return 0;
-}
-
static int constant_set_state_periodic(struct clock_event_device *evt)
{
unsigned long period;
@@ -92,6 +77,14 @@ static int constant_set_state_periodic(struct clock_event_device *evt)
static int constant_set_state_shutdown(struct clock_event_device *evt)
{
+ unsigned long timer_config;
+
+ raw_spin_lock(&state_lock);
+ timer_config = csr_read64(LOONGARCH_CSR_TCFG);
+ timer_config &= ~CSR_TCFG_EN;
+ csr_write64(timer_config, LOONGARCH_CSR_TCFG);
+ raw_spin_unlock(&state_lock);
+
return 0;
}
@@ -161,7 +154,7 @@ int constant_clockevent_init(void)
cd->rating = 320;
cd->cpumask = cpumask_of(cpu);
cd->set_state_oneshot = constant_set_state_oneshot;
- cd->set_state_oneshot_stopped = constant_set_state_oneshot_stopped;
+ cd->set_state_oneshot_stopped = constant_set_state_shutdown;
cd->set_state_periodic = constant_set_state_periodic;
cd->set_state_shutdown = constant_set_state_shutdown;
cd->set_next_event = constant_timer_next_event;
base-commit: 037266a5f7239ead1530266f7d7af153d2a867fa
--
2.39.3
Powered by blists - more mailing lists