Skip to contentSkip to conversation

clocksource/drivers/timer-ti-dm: handle runtime resume failure

PATCH Applied Jiale Yao 2 participants 2 messages Oct 3 – Oct 14 Clocksource, clockevent drivers

lore
Share & tools
lore

Jiale Yao

author
#0 lore raw

PATCH 1/1 clocksource/drivers/timer-ti-dm: handle runtime resume failure

omap_dm_timer_write_counter() accesses timer registers and updates the saved counter value after requesting a runtime PM reference. If runtime resume fails, the timer remains inaccessible and no reference is acquired, but the function still writes the register, drops a reference, updates the cached value, and reports success.

Check the return value and propagate an error before touching the timer state.

Fixes 0494fc345b37 ("clocksource/drivers/timer-ti-dm : Capture functionality for OMAP DM timer")
---
 drivers/clocksource/timer-ti-dm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm.c +5 -1
index 6787acac9a43..399321ea7915 100644
@@ -1095,6 +1095,7 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in
 {
 	struct dmtimer *timer;
 	struct device *dev;
+	int ret;
 
 	timer = to_dmtimer(cookie);
 	if (unlikely(!timer)) {
@@ -1104,7 +1105,10 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in
 
 	dev = &timer->pdev->dev;
 
-	pm_runtime_resume_and_get(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0)
+		return ret;
+
 	dmtimer_write(timer, OMAP_TIMER_COUNTER_REG, value);
 	pm_runtime_put_sync(dev);
 
Signature · 1 line
2.34.1
#1 lore raw

[clocksource: timers/drivers/next] clocksource/drivers/timer-ti-dm: Handle runtime resume failure

The following commit has been merged into the timers/drivers/next branch of clocksource:

The following commit has been merged into the timers/drivers/next branch of clocksource:

Commit-ID:     c40b76c8cf580466d9e56223f7f74beecc165480
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/daniel.lezcano/linux.git//c40b76c8cf580466d9e56223f7f74beecc165480
Author:        Jiale Yao <[email protected]>
AuthorDate:    Sat, 03 Oct 2026 16:08:11 +08:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 14 Oct 2026 20:43:56 +02:00

clocksource/drivers/timer-ti-dm: Handle runtime resume failure

omap_dm_timer_write_counter() accesses timer registers and updates the saved counter value after requesting a runtime PM reference. If runtime resume fails, the timer remains inaccessible and no reference is acquired, but the function still writes the register, drops a reference, updates the cached value, and reports success.

Check the return value and propagate an error before touching the timer state.

Fixes 0494fc345b37 ("clocksource/drivers/timer-ti-dm : Capture functionality for OMAP DM timer")
---
 drivers/clocksource/timer-ti-dm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm.c +5 -1
index ae8777d..8012d3f 100644
@@ -1095,6 +1095,7 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in
 {
 	struct dmtimer *timer;
 	struct device *dev;
+	int ret;
 
 	timer = to_dmtimer(cookie);
 	if (unlikely(!timer)) {
@@ -1104,7 +1105,10 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in
 
 	dev = &timer->pdev->dev;
 
-	pm_runtime_resume_and_get(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0)
+		return ret;
+
 	dmtimer_write(timer, OMAP_TIMER_COUNTER_REG, value);
 	pm_runtime_put_sync(dev);