Skip to contentSkip to conversation

mlxsw: Fix 64-bit division in mlxsw_sp_sb_prs_init

PATCH Applied Nathan Chancellor 3 participants 3 messages Oct 30, 2019 – Oct 31, 2019

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

PATCH 1/1 mlxsw: Fix 64-bit division in mlxsw_sp_sb_prs_init

When building for 32-bit ARM, there is a link time error because of a 64-bit division:

ld.lld: error: undefined symbol: __aeabi_uldivmod

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by spectrum_buffers.c
net/ethernet/mellanox/mlxsw/spectrum_buffers.o:(mlxsw_sp_buffers_init) in archive drivers/built-in.a
did you mean: __aeabi_uidivmod
defined in: arch/arm/lib/lib.a(lib1funcs.o

Avoid this by using div_u64, which is designed to avoid this problem.

Fixes bc9f6e94bcb5 ("mlxsw: spectrum_buffers: Calculate the size of the main pool")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +1 -1
index 33a978af80d6..968f0902e4fe 100644
@@ -470,7 +470,7 @@ static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
 				size_t prs_len)
 {
 	/* Round down, unlike mlxsw_sp_bytes_cells(). */
-	u32 sb_cells = mlxsw_sp->sb->sb_size / mlxsw_sp->sb->cell_size;
+	u32 sb_cells = div_u64(mlxsw_sp->sb->sb_size, mlxsw_sp->sb->cell_size);
 	u32 rest_cells[2] = {sb_cells, sb_cells};
 	int i;
 	int err;
Signature · 1 line
2.24.0.rc1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Nathan Chancellor

When building for 32-bit ARM, there is a link time error because of a 64-bit division:

ld.lld: error: undefined symbol: __aeabi_uldivmod

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by spectrum_buffers.c
net/ethernet/mellanox/mlxsw/spectrum_buffers.o:(mlxsw_sp_buffers_init) in archive drivers/built-in.a
did you mean: __aeabi_uidivmod
defined in: arch/arm/lib/lib.a(lib1funcs.o

Quoted 4 lines

Avoid this by using div_u64, which is designed to avoid this problem.

Fixes bc9f6e94bcb5 ("mlxsw: spectrum_buffers: Calculate the size of the main pool")

Thanks, Nathan!

maintainer Applied
#2 lore raw
In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>
Date: Wed, 30 Oct 2019 09:01:52 -0700

Quoted 9 lines

When building for 32-bit ARM, there is a link time error because of a 64-bit division:

ld.lld: error: undefined symbol: __aeabi_uldivmod

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by spectrum_buffers.c
net/ethernet/mellanox/mlxsw/spectrum_buffers.o:(mlxsw_sp_buffers_init) in archive drivers/built-in.a
did you mean: __aeabi_uidivmod
defined in: arch/arm/lib/lib.a(lib1funcs.o

Quoted 4 lines

Avoid this by using div_u64, which is designed to avoid this problem.

Fixes bc9f6e94bcb5 ("mlxsw: spectrum_buffers: Calculate the size of the main pool")

Applied, thanks.