Skip to contentSkip to conversation

clocksource/drivers/tegra: Unwind timer setup on CPUHP failure

PATCH New Yuho Choi 1 participant 1 message Aug 2

Subsystems (2)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 clocksource/drivers/tegra: Unwind timer setup on CPUHP failure

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")
---
 drivers/clocksource/timer-tegra.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/clocksource/timer-tegra.c +9 -7
index 35b6ce9deffa..bfcd0a57d856 100644
@@ -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) {
Signature · 1 line
2.43.0