Skip to contentSkip to conversation

mlxsw: spectrum_ptp: fix 32-bit build

PATCH In review Arnd Bergmann 3 participants 3 messages Jun 19, 2019 – Jun 20, 2019

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

PATCH 1/1 mlxsw: spectrum_ptp: fix 32-bit build

On 32-bit architectures, we cannot easily device 64-bit numbers:

ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!

Use do_div() to annotate the fact that we know this is an expensive operation.

Fixes 992aa864dca0 ("mlxsw: spectrum_ptp: Add implementation for physical hardware clock operations")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +1 -1
index 2a9bbc90225e..618e329e1490 100644
@@ -87,7 +87,7 @@ mlxsw_sp1_ptp_phc_settime(struct mlxsw_sp_ptp_clock *clock, u64 nsec)
 	u32 next_sec;
 	int err;
 
-	next_sec = nsec / NSEC_PER_SEC + 1;
+	next_sec = div_u64(nsec, NSEC_PER_SEC) + 1;
 	next_sec_in_nsec = next_sec * NSEC_PER_SEC;
 
 	spin_lock(&clock->lock);
Signature · 1 line
2.20.0
#1 lore raw
Quoted 9 lines · Arnd Bergmann

On 32-bit architectures, we cannot easily device 64-bit numbers:

ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!

Use do_div() to annotate the fact that we know this is an expensive operation.

Fixes 992aa864dca0 ("mlxsw: spectrum_ptp: Add implementation for physical hardware clock operations")

Arnd, thanks for the patch. We already patched this issue yesterday:
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=cd4bb2a3344cb53d9234cca232edfb2dce0f0a35

#2 lore raw
In reply to Arnd Bergmann

Hello!

Quoted 1 line · Arnd Bergmann

On 32-bit architectures, we cannot easily device 64-bit numbers:

s/device/divide/?

Quoted 3 lines

ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!

Use do_div() to annotate the fact that we know this is an

div_u64() really?

Quoted 13 lines

expensive operation.

Fixes 992aa864dca0 ("mlxsw: spectrum_ptp: Add implementation for physical hardware clock operations")
---
  drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +0 -0
index 2a9bbc90225e..618e329e1490 100644

drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c mlxsw_sp1_ptp_phc_settime(struct mlxsw_sp_ptp_clock *clock, u64 nsec) · line 93

Quoted 8 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +1 -1
@@ -87,7 +87,7 @@ mlxsw_sp1_ptp_phc_settime(struct mlxsw_sp_ptp_clock *clock, u64 nsec)
  	u32 next_sec;
  	int err;
 
-	next_sec = nsec / NSEC_PER_SEC + 1;
+	next_sec = div_u64(nsec, NSEC_PER_SEC) + 1;
  	next_sec_in_nsec = next_sec * NSEC_PER_SEC;
 
  	spin_lock(&clock->lock);

MBR, Sergei