[PATCH 1/2] riscv: Fix spurious warning when cpu_is_stopped callback is absent

From: Rui Qi

Date: Thu Aug 13 2026 - 09:06:27 EST


Commit 2b2b207e1162 ("riscv: cpu_ops: Change return value type of
cpu_is_stopped() to bool") inverted the warning condition from
if (ret) to if (!ret) to match the new bool semantics where false
means "not stopped". However, ret is initialized to 0, so when the
cpu_is_stopped callback is NULL (the callback is optional), ret
remains 0 and if (!ret) evaluates to true, causing a spurious
"CPU%u may not have stopped" warning on every CPU offlining.

Move the warning inside the callback existence check so that the
firmware verification only happens when the backend actually
provides the callback. This also eliminates the now-unneeded ret
variable.

Fixes: 2b2b207e1162 ("riscv: cpu_ops: Change return value type of cpu_is_stopped() to bool")
Signed-off-by: Rui Qi <qirui.001@xxxxxxxxxxxxx>
---
arch/riscv/kernel/cpu-hotplug.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/riscv/kernel/cpu-hotplug.c b/arch/riscv/kernel/cpu-hotplug.c
index 0bc56d8381b6..4c3dfc0efbee 100644
--- a/arch/riscv/kernel/cpu-hotplug.c
+++ b/arch/riscv/kernel/cpu-hotplug.c
@@ -49,15 +49,11 @@ int __cpu_disable(void)
*/
void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
{
- int ret = 0;
-
pr_notice("CPU%u: off\n", cpu);

clear_tasks_mm_cpumask(cpu);
/* Verify from the firmware if the cpu is really stopped*/
- if (cpu_ops->cpu_is_stopped)
- ret = cpu_ops->cpu_is_stopped(cpu);
- if (!ret)
+ if (cpu_ops->cpu_is_stopped && !cpu_ops->cpu_is_stopped(cpu))
pr_warn("CPU%u may not have stopped\n", cpu);
}

--
2.20.1