Skip to contentSkip to conversation

clocksource: imx-tpm: correct -ETIME return condition check

PATCH In review Anson Huang 3 participants 3 messages Apr 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: imx-tpm: correct -ETIME return condition check

The additional brakets added to tpm_set_next_event's return value computation causes (int) forced type conversion NOT taking effect, and the incorrect value return will cause various system timer issue, like RCU stall etc..

This patch removes the additional brakets to make sure tpm_set_next_event always returns correct value.

---
resend, since I got failure message of sending mail to [email protected].

 drivers/clocksource/timer-imx-tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-imx-tpm.c +1 -1
index 05d97a6..6c83184 100644
@@ -114,7 +114,7 @@ static int tpm_set_next_event(unsigned long delta,
 	 * of writing CNT registers which may cause the min_delta event got
 	 * missed, so we need add a ETIME check here in case it happened.
 	 */
-	return (int)((next - now) <= 0) ? -ETIME : 0;
+	return (int)(next - now) <= 0 ? -ETIME : 0;
 }
 
 static int tpm_set_state_oneshot(struct clock_event_device *evt)
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Anson Huang
Sent: Thursday, April 19, 2018 2:05 PM
To: [email protected]; [email protected]; linux- [email protected]
Cc: dl-linux-imx <[email protected]>
Subject: [PATCH] clocksource: imx-tpm: correct -ETIME return condition check

Quoted 8 lines

The additional brakets added to tpm_set_next_event's return value computation causes (int) forced type conversion NOT taking effect, and the incorrect value return will cause various system timer issue, like RCU stall etc..

This patch removes the additional brakets to make sure tpm_set_next_event always returns correct value.

It's my mistake. Thanks for spotting it out.

Regards
Dong Aisheng

Quoted 22 lines

---
resend, since I got failure message of sending mail to linux-
[email protected].

 drivers/clocksource/timer-imx-tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer- renamed from drivers/clocksource/timer-imx-tpm.c +0 -0

imx-tpm.c
index 05d97a6..6c83184 100644

drivers/clocksource/timer-imx-tpm.c +1 -2
@@ -114,7 +114,7 @@ static int tpm_set_next_event(unsigned long delta,
 	 * of writing CNT registers which may cause the min_delta event got
 	 * missed, so we need add a ETIME check here in case it happened.
 	 */
-	return (int)((next - now) <= 0) ? -ETIME : 0;
+	return (int)(next - now) <= 0 ? -ETIME : 0;
 }
 
 static int tpm_set_state_oneshot(struct clock_event_device *evt)
--

2.7.4

#2 lore raw

[tip:timers/urgent] clocksource/imx-tpm: Correct -ETIME return condition check

In reply to Anson Huang
clocksource/imx-tpm: Correct -ETIME return condition check
Commit-ID:  7407188489c62a7b5694bc75a6db2b82af94c9a5
Gitweb:     https://git.kernel.org/tip/7407188489c62a7b5694bc75a6db2b82af94c9a5
Author:     Anson Huang <[email protected]>
AuthorDate: Thu, 19 Apr 2018 14:04:43 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 19 Apr 2018 13:21:35 +0200

clocksource/imx-tpm: Correct -ETIME return condition check

The additional brakects added to tpm_set_next_event's return value computation causes (int) forced type conversion NOT taking effect, and the incorrect value return will cause various system timer issue, like RCU stall etc..

Remove the additional brackets to make sure tpm_set_next_event always returns correct value.

---
 drivers/clocksource/timer-imx-tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-imx-tpm.c +1 -1
index 05d97a6871d8..6c8318470b48 100644
@@ -114,7 +114,7 @@ static int tpm_set_next_event(unsigned long delta,
 	 * of writing CNT registers which may cause the min_delta event got
 	 * missed, so we need add a ETIME check here in case it happened.
 	 */
-	return (int)((next - now) <= 0) ? -ETIME : 0;
+	return (int)(next - now) <= 0 ? -ETIME : 0;
 }
 
 static int tpm_set_state_oneshot(struct clock_event_device *evt)