* [PATCH] clocksource: tegra186: avoid 64-bit division
@ 2025-06-20 11:19 Arnd Bergmann
2025-06-24 10:06 ` Jon Hunter
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Arnd Bergmann @ 2025-06-20 11:19 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, Thierry Reding, Jonathan Hunter,
Pohsun Su, Robert Lin
Cc: Arnd Bergmann, linux-kernel, linux-tegra
From: Arnd Bergmann <arnd@arndb.de>
The newly added function causes a build failure on 32-bit targets with
older compiler version such as gcc-10:
arm-linux-gnueabi-ld: drivers/clocksource/timer-tegra186.o: in function `tegra186_wdt_get_timeleft':
timer-tegra186.c:(.text+0x3c2): undefined reference to `__aeabi_uldivmod'
The calculation can trivially be changed to avoid the division entirely,
as USEC_PER_SEC is a multiple of 5. Change both such calculation for
consistency, even though gcc apparently managed to optimize the other one
properly already.
Fixes: 28c842c8b0f5 ("clocksource/drivers/timer-tegra186: Add WDIOC_GETTIMELEFT support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/clocksource/timer-tegra186.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
index e5394f98a02e..bd3d443e41cd 100644
--- a/drivers/clocksource/timer-tegra186.c
+++ b/drivers/clocksource/timer-tegra186.c
@@ -159,7 +159,7 @@ static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
tmr_writel(wdt->tmr, TMRCSSR_SRC_USEC, TMRCSSR);
/* configure timer (system reset happens on the fifth expiration) */
- value = TMRCR_PTV(wdt->base.timeout * USEC_PER_SEC / 5) |
+ value = TMRCR_PTV(wdt->base.timeout * (USEC_PER_SEC / 5)) |
TMRCR_PERIODIC | TMRCR_ENABLE;
tmr_writel(wdt->tmr, value, TMRCR);
@@ -267,7 +267,7 @@ static unsigned int tegra186_wdt_get_timeleft(struct watchdog_device *wdd)
* counter value to the time of the counter expirations that
* remain.
*/
- timeleft += (((u64)wdt->base.timeout * USEC_PER_SEC) / 5) * (4 - expiration);
+ timeleft += (u64)wdt->base.timeout * (USEC_PER_SEC / 5) * (4 - expiration);
/*
* Convert the current counter value to seconds,
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource: tegra186: avoid 64-bit division
2025-06-20 11:19 [PATCH] clocksource: tegra186: avoid 64-bit division Arnd Bergmann
@ 2025-06-24 10:06 ` Jon Hunter
2025-06-24 10:20 ` Arnd Bergmann
2025-07-15 11:12 ` Daniel Lezcano
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Jon Hunter @ 2025-06-24 10:06 UTC (permalink / raw)
To: Arnd Bergmann, Daniel Lezcano, Thomas Gleixner, Thierry Reding,
Pohsun Su, Robert Lin, Guenter Roeck
Cc: Arnd Bergmann, linux-kernel, linux-tegra
On 20/06/2025 12:19, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The newly added function causes a build failure on 32-bit targets with
> older compiler version such as gcc-10:
>
> arm-linux-gnueabi-ld: drivers/clocksource/timer-tegra186.o: in function `tegra186_wdt_get_timeleft':
> timer-tegra186.c:(.text+0x3c2): undefined reference to `__aeabi_uldivmod'
>
> The calculation can trivially be changed to avoid the division entirely,
> as USEC_PER_SEC is a multiple of 5. Change both such calculation for
> consistency, even though gcc apparently managed to optimize the other one
> properly already.
>
> Fixes: 28c842c8b0f5 ("clocksource/drivers/timer-tegra186: Add WDIOC_GETTIMELEFT support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/clocksource/timer-tegra186.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
> index e5394f98a02e..bd3d443e41cd 100644
> --- a/drivers/clocksource/timer-tegra186.c
> +++ b/drivers/clocksource/timer-tegra186.c
> @@ -159,7 +159,7 @@ static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
> tmr_writel(wdt->tmr, TMRCSSR_SRC_USEC, TMRCSSR);
>
> /* configure timer (system reset happens on the fifth expiration) */
> - value = TMRCR_PTV(wdt->base.timeout * USEC_PER_SEC / 5) |
> + value = TMRCR_PTV(wdt->base.timeout * (USEC_PER_SEC / 5)) |
> TMRCR_PERIODIC | TMRCR_ENABLE;
> tmr_writel(wdt->tmr, value, TMRCR);
>
> @@ -267,7 +267,7 @@ static unsigned int tegra186_wdt_get_timeleft(struct watchdog_device *wdd)
> * counter value to the time of the counter expirations that
> * remain.
> */
> - timeleft += (((u64)wdt->base.timeout * USEC_PER_SEC) / 5) * (4 - expiration);
> + timeleft += (u64)wdt->base.timeout * (USEC_PER_SEC / 5) * (4 - expiration);
>
> /*
> * Convert the current counter value to seconds,
Guenter has also posted a fix for this here [0].
Jon
[0]
https://lore.kernel.org/linux-tegra/75496de8-51fd-4e27-9f92-babaa0e22c14@nvidia.com/T/#me403a7afd04bbf24e29d3880123a4faa656eab05
--
nvpublic
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource: tegra186: avoid 64-bit division
2025-06-24 10:06 ` Jon Hunter
@ 2025-06-24 10:20 ` Arnd Bergmann
0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2025-06-24 10:20 UTC (permalink / raw)
To: Jon Hunter, Arnd Bergmann, Daniel Lezcano, Thomas Gleixner,
Thierry Reding, Pohsun Su, Robert Lin, Guenter Roeck
Cc: linux-kernel, linux-tegra
On Tue, Jun 24, 2025, at 12:06, Jon Hunter wrote:
> On 20/06/2025 12:19, Arnd Bergmann wrote:
>> @@ -267,7 +267,7 @@ static unsigned int tegra186_wdt_get_timeleft(struct watchdog_device *wdd)
>> * counter value to the time of the counter expirations that
>> * remain.
>> */
>> - timeleft += (((u64)wdt->base.timeout * USEC_PER_SEC) / 5) * (4 - expiration);
>> + timeleft += (u64)wdt->base.timeout * (USEC_PER_SEC / 5) * (4 - expiration);
>>
>> /*
>> * Convert the current counter value to seconds,
>
>
> Guenter has also posted a fix for this here [0].
>
Right, that one looks better than mine, as it avoids another
division entirely.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clocksource: tegra186: avoid 64-bit division
2025-06-20 11:19 [PATCH] clocksource: tegra186: avoid 64-bit division Arnd Bergmann
2025-06-24 10:06 ` Jon Hunter
@ 2025-07-15 11:12 ` Daniel Lezcano
2025-07-23 7:17 ` [tip: timers/clocksource] clocksource/drivers/tegra186: Avoid " tip-bot2 for Arnd Bergmann
2025-07-25 10:31 ` tip-bot2 for Arnd Bergmann
3 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2025-07-15 11:12 UTC (permalink / raw)
To: Arnd Bergmann, Thomas Gleixner, Thierry Reding, Jonathan Hunter,
Pohsun Su, Robert Lin
Cc: Arnd Bergmann, linux-kernel, linux-tegra
On 6/20/25 13:19, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The newly added function causes a build failure on 32-bit targets with
> older compiler version such as gcc-10:
>
> arm-linux-gnueabi-ld: drivers/clocksource/timer-tegra186.o: in function `tegra186_wdt_get_timeleft':
> timer-tegra186.c:(.text+0x3c2): undefined reference to `__aeabi_uldivmod'
>
> The calculation can trivially be changed to avoid the division entirely,
> as USEC_PER_SEC is a multiple of 5. Change both such calculation for
> consistency, even though gcc apparently managed to optimize the other one
> properly already.
>
> Fixes: 28c842c8b0f5 ("clocksource/drivers/timer-tegra186: Add WDIOC_GETTIMELEFT support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Applied, thanks
Fixed conflict with
https://lore.kernel.org/r/20250614175556.922159-2-linux@roeck-us.net
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: timers/clocksource] clocksource/drivers/tegra186: Avoid 64-bit division
2025-06-20 11:19 [PATCH] clocksource: tegra186: avoid 64-bit division Arnd Bergmann
2025-06-24 10:06 ` Jon Hunter
2025-07-15 11:12 ` Daniel Lezcano
@ 2025-07-23 7:17 ` tip-bot2 for Arnd Bergmann
2025-07-25 10:31 ` tip-bot2 for Arnd Bergmann
3 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2025-07-23 7:17 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Arnd Bergmann, Daniel Lezcano, x86, linux-kernel
The following commit has been merged into the timers/clocksource branch of tip:
Commit-ID: 7e11b4f49b5147817cd87489d4e63ca9fc92753c
Gitweb: https://git.kernel.org/tip/7e11b4f49b5147817cd87489d4e63ca9fc92753c
Author: Arnd Bergmann <arnd@arndb.de>
AuthorDate: Fri, 20 Jun 2025 13:19:35 +02:00
Committer: Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Tue, 15 Jul 2025 13:09:35 +02:00
clocksource/drivers/tegra186: Avoid 64-bit division
The newly added function causes a build failure on 32-bit targets with
older compiler version such as gcc-10:
arm-linux-gnueabi-ld: drivers/clocksource/timer-tegra186.o: in function `tegra186_wdt_get_timeleft':
timer-tegra186.c:(.text+0x3c2): undefined reference to `__aeabi_uldivmod'
The calculation can trivially be changed to avoid the division entirely,
as USEC_PER_SEC is a multiple of 5. Change both such calculation for
consistency, even though gcc apparently managed to optimize the other one
properly already.
Fixes: 28c842c8b0f5 ("clocksource/drivers/timer-tegra186: Add WDIOC_GETTIMELEFT support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250620111939.3395525-1-arnd@kernel.org
[dlezcano] : Fixed conflict with 20250614175556.922159-2-linux@roeck-us.net
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/clocksource/timer-tegra186.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
index d403a3f..1ec7b38 100644
--- a/drivers/clocksource/timer-tegra186.c
+++ b/drivers/clocksource/timer-tegra186.c
@@ -159,7 +159,7 @@ static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
tmr_writel(wdt->tmr, TMRCSSR_SRC_USEC, TMRCSSR);
/* configure timer (system reset happens on the fifth expiration) */
- value = TMRCR_PTV(wdt->base.timeout * USEC_PER_SEC / 5) |
+ value = TMRCR_PTV(wdt->base.timeout * (USEC_PER_SEC / 5)) |
TMRCR_PERIODIC | TMRCR_ENABLE;
tmr_writel(wdt->tmr, value, TMRCR);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip: timers/clocksource] clocksource/drivers/tegra186: Avoid 64-bit division
2025-06-20 11:19 [PATCH] clocksource: tegra186: avoid 64-bit division Arnd Bergmann
` (2 preceding siblings ...)
2025-07-23 7:17 ` [tip: timers/clocksource] clocksource/drivers/tegra186: Avoid " tip-bot2 for Arnd Bergmann
@ 2025-07-25 10:31 ` tip-bot2 for Arnd Bergmann
3 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2025-07-25 10:31 UTC (permalink / raw)
To: linux-tip-commits
Cc: Arnd Bergmann, Daniel Lezcano, Ingo Molnar, x86, linux-kernel
The following commit has been merged into the timers/clocksource branch of tip:
Commit-ID: 836758dc1e43928aa1a357009f5c3164a00cbfb0
Gitweb: https://git.kernel.org/tip/836758dc1e43928aa1a357009f5c3164a00cbfb0
Author: Arnd Bergmann <arnd@arndb.de>
AuthorDate: Fri, 20 Jun 2025 13:19:35 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 25 Jul 2025 12:06:46 +02:00
clocksource/drivers/tegra186: Avoid 64-bit division
The newly added function causes a build failure on 32-bit targets with
older compiler version such as gcc-10:
arm-linux-gnueabi-ld: drivers/clocksource/timer-tegra186.o: in function `tegra186_wdt_get_timeleft':
timer-tegra186.c:(.text+0x3c2): undefined reference to `__aeabi_uldivmod'
The calculation can trivially be changed to avoid the division entirely,
as USEC_PER_SEC is a multiple of 5. Change both such calculation for
consistency, even though gcc apparently managed to optimize the other one
properly already.
[ dlezcano : Fixed conflict with 20250614175556.922159-2-linux@roeck-us.net ]
Fixes: 28c842c8b0f5 ("clocksource/drivers/timer-tegra186: Add WDIOC_GETTIMELEFT support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250620111939.3395525-1-arnd@kernel.org
---
drivers/clocksource/timer-tegra186.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-tegra186.c b/drivers/clocksource/timer-tegra186.c
index d403a3f..1ec7b38 100644
--- a/drivers/clocksource/timer-tegra186.c
+++ b/drivers/clocksource/timer-tegra186.c
@@ -159,7 +159,7 @@ static void tegra186_wdt_enable(struct tegra186_wdt *wdt)
tmr_writel(wdt->tmr, TMRCSSR_SRC_USEC, TMRCSSR);
/* configure timer (system reset happens on the fifth expiration) */
- value = TMRCR_PTV(wdt->base.timeout * USEC_PER_SEC / 5) |
+ value = TMRCR_PTV(wdt->base.timeout * (USEC_PER_SEC / 5)) |
TMRCR_PERIODIC | TMRCR_ENABLE;
tmr_writel(wdt->tmr, value, TMRCR);
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-07-25 10:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 11:19 [PATCH] clocksource: tegra186: avoid 64-bit division Arnd Bergmann
2025-06-24 10:06 ` Jon Hunter
2025-06-24 10:20 ` Arnd Bergmann
2025-07-15 11:12 ` Daniel Lezcano
2025-07-23 7:17 ` [tip: timers/clocksource] clocksource/drivers/tegra186: Avoid " tip-bot2 for Arnd Bergmann
2025-07-25 10:31 ` tip-bot2 for Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).