Skip to contentSkip to conversation

clk: sophgo: avoid open-coded 64-bit division

PATCH Applied Arnd Bergmann 3 participants 4 messages Apr 15, 2024 – Apr 19, 2024

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

PATCH 1/1 clk: sophgo: avoid open-coded 64-bit division

From: Arnd Bergmann <[email protected]>

On 32-bit architectures, the 64-bit division leads to a link failure:

arm-linux-gnueabi-ld: drivers/clk/sophgo/clk-cv18xx-pll.o: in function `fpll_calc_rate':
clk-cv18xx-pll.c:(.text.fpll_calc_rate+0x26): undefined reference to `__aeabi_uldivmod'

This one is not called in a fast path, and there is already another div_u64() variant used in the same function, so convert it to div64_u64_rem().

Fixes 80fd61ec4612 ("clk: sophgo: Add clock support for CV1800 SoC")
---
 drivers/clk/sophgo/clk-cv18xx-pll.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/sophgo/clk-cv18xx-pll.c +1 -2
index c546dad1791c..29e24098bf5f 100644
@@ -205,8 +205,7 @@ static unsigned long fpll_calc_rate(unsigned long parent_rate,
 	unsigned long rate;
 
 	dividend <<= PLL_SYN_FACTOR_DOT_POS - 1;
-	rate = dividend / factor;
-	dividend %= factor;
+	rate = div64_u64_rem(dividend, factor, &dividend);
 
 	if (is_full_parent) {
 		dividend <<= 1;
Signature · 1 line
2.39.2
#1 lore raw
Quoted 4 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

On 32-bit architectures, the 64-bit division leads to a link failure:

Quoted 8 lines

arm-linux-gnueabi-ld: drivers/clk/sophgo/clk-cv18xx-pll.o: in function `fpll_calc_rate':
clk-cv18xx-pll.c:(.text.fpll_calc_rate+0x26): undefined reference to `__aeabi_uldivmod'

This one is not called in a fast path, and there is already another div_u64() variant used in the same function, so convert it to div64_u64_rem().

Fixes 80fd61ec4612 ("clk: sophgo: Add clock support for CV1800 SoC")

There is already a fix patch:
https://lore.kernel.org/all/IA1PR20MB4953CB4FCCDE82AB25F6880EBB0B2@IA1PR20MB4953.namprd20.prod.outlook.com/

Reviewed-by
#2 lore raw
Quoted 8 lines · Inochi Amaoto
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

On 32-bit architectures, the 64-bit division leads to a link failure:

arm-linux-gnueabi-ld: drivers/clk/sophgo/clk-cv18xx-pll.o: in function `fpll_calc_rate':
clk-cv18xx-pll.c:(.text.fpll_calc_rate+0x26): undefined reference to `__aeabi_uldivmod'

Quoted 8 lines
Quoted 5 lines

This one is not called in a fast path, and there is already another div_u64() variant used in the same function, so convert it to div64_u64_rem().

Fixes 80fd61ec4612 ("clk: sophgo: Add clock support for CV1800 SoC")

There is already a fix patch:
https://lore.kernel.org/all/IA1PR20MB4953CB4FCCDE82AB25F6880EBB0B2@IA1PR20MB4953.namprd20.prod.outlook.com/

Hi Arnd,

I have looked your patch again and think your patch is better than mine. So I decided to drop my patch and favor yours.

LGTM. And there are some necessary tags.

maintainer Applied
#3 lore raw
In reply to Arnd Bergmann

Quoting Arnd Bergmann (2024-04-15 06:45:20)

Quoted 7 lines

From: Arnd Bergmann <[email protected]>

On 32-bit architectures, the 64-bit division leads to a link failure:

arm-linux-gnueabi-ld: drivers/clk/sophgo/clk-cv18xx-pll.o: in function `fpll_calc_rate':
clk-cv18xx-pll.c:(.text.fpll_calc_rate+0x26): undefined reference to `__aeabi_uldivmod'

Quoted 6 lines

This one is not called in a fast path, and there is already another div_u64() variant used in the same function, so convert it to div64_u64_rem().

Fixes 80fd61ec4612 ("clk: sophgo: Add clock support for CV1800 SoC")

---

Applied to clk-next