Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Yuho Choi <dbgh9129@gmail.com>
To: daniel.lezcano@kernel.org
Cc: tglx@kernel.org, thierry.reding@kernel.org, jonathanh@nvidia.com,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] clocksource/drivers/tegra: Unwind timer setup on CPUHP failure
Date: Sun,  2 Aug 2026 19:35:29 -0400	[thread overview]
Message-ID: <20260802233529.598707-1-dbgh9129@gmail.com> (raw)

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 <dbgh9129@gmail.com>
---
 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


                 reply	other threads:[~2026-08-02 23:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260802233529.598707-1-dbgh9129@gmail.com \
    --to=dbgh9129@gmail.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=thierry.reding@kernel.org \
    /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