[PATCH v1] clocksource/drivers/tegra: Unwind timer setup on CPUHP failure
Yuho Choi <[email protected]> Sun, 2 Aug 2026 19:35:29 -0400
| Newsgroups | org.kernel.vger.linux-tegra,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
The Tegra timer requests per-CPU interrupts before registering its CPU
hotplug state. If cpuhp_setup_state() fails, the function returns directly
and leaves the requested interrupts registered.
Register the CPU hotplug state before registering the sched clock and
clocksource. On failure, unwind through the existing IRQ cleanup path so
that no registered clocksource is left pointing at an unmapped timer base.
Fixes: b4822dc7564f ("clocksource/drivers/tegra: Add Tegra210 timer support")
Signed-off-by: Yuho Choi <[email protected]>
---
drivers/clocksource/timer-tegra.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/clocksource/timer-tegra.c b/drivers/clocksource/timer-tegra.c
index 35b6ce9deffa..bfcd0a57d856 100644
--- a/drivers/clocksource/timer-tegra.c
+++ b/drivers/clocksource/timer-tegra.c
@@ -331,6 +331,14 @@ static int __init tegra_init_timer(struct device_node *np, bool tegra20,
}
}
+ ret = cpuhp_setup_state(CPUHP_AP_TEGRA_TIMER_STARTING,
+ "AP_TEGRA_TIMER_STARTING", tegra_timer_setup,
+ tegra_timer_stop);
+ if (ret) {
+ pr_err("failed to set up cpu hp state: %d\n", ret);
+ goto out_irq;
+ }
+
sched_clock_register(tegra_read_sched_clock, 32, TIMER_1MHz);
ret = clocksource_mmio_init(timer_reg_base + TIMERUS_CNTR_1US,
@@ -343,13 +351,7 @@ static int __init tegra_init_timer(struct device_node *np, bool tegra20,
register_current_timer_delay(&tegra_delay_timer);
#endif
- ret = cpuhp_setup_state(CPUHP_AP_TEGRA_TIMER_STARTING,
- "AP_TEGRA_TIMER_STARTING", tegra_timer_setup,
- tegra_timer_stop);
- if (ret)
- pr_err("failed to set up cpu hp state: %d\n", ret);
-
- return ret;
+ return 0;
out_irq:
for_each_possible_cpu(cpu) {
--
2.43.0