mlx5: avoid 64-bit division in dr_icm_pool_mr_create()
Subsystems (4)
PATCH 1/1 mlx5: avoid 64-bit division in dr_icm_pool_mr_create()
Recently added code introduces 64-bit division in dr_icm_pool_mr_create() so that build on 32-bit architectures fails with
ERROR: "__umoddi3" [drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] undefined!
As the divisor is always a power of 2, we can use bitwise operation instead.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +2 -1
@@ -137,7 +137,8 @@ dr_icm_pool_mr_create(struct mlx5dr_icm_pool *pool, icm_mr->icm_start_addr = icm_mr->dm.addr; - align_diff = icm_mr->icm_start_addr % align_base; +/* align_base is always a power of 2 */ + align_diff = icm_mr->icm_start_addr & (align_base -1 );if (align_diff) icm_mr->used_length = align_base - align_diff;
Signature · 1 line
2.23.0
Quoted 20 lines · Michal Kubecek
Recently added code introduces 64-bit division in
dr_icm_pool_mr_create()so that build on 32-bit architectures fails withERROR: "
__umoddi3" [drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] undefined!As the divisor is always a power of 2, we can use bitwise operation instead.
Fixes 29cf8febd185 ("net/mlx5: DR, ICM pool memory allocator")Reported-by Borislav Petkov <[email protected]>Signed-off-by Michal Kubecek <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c dr_icm_pool_mr_create(struct mlx5dr_icm_pool *pool, · line 144
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +2
-1@@ -137,7 +137,8 @@ dr_icm_pool_mr_create(struct mlx5dr_icm_pool *pool, icm_mr->icm_start_addr = icm_mr->dm.addr; - align_diff = icm_mr->icm_start_addr % align_base; +/* align_base is always a power of 2 */ + align_diff = icm_mr->icm_start_addr & (align_base -1 );if (align_diff) icm_mr->used_length = align_base - align_diff;
Align diff is power of 2, looks good to me.
Thanks for fixing it Michal.
David Miller
maintainerFrom: Alex Vesker <[email protected]>
Date: Wed, 2 Oct 2019 14:58:44 +0000
Quoted 12 lines · Michal Kubecek
Quoted 11 lines
Recently added code introduces 64-bit division in
dr_icm_pool_mr_create()so that build on 32-bit architectures fails withERROR: "
__umoddi3" [drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] undefined!As the divisor is always a power of 2, we can use bitwise operation instead.
Fixes 29cf8febd185 ("net/mlx5: DR, ICM pool memory allocator")Reported-by Borislav Petkov <[email protected]>Signed-off-by Michal Kubecek <[email protected]>
...
Quoted 2 lines
Align diff is power of 2, looks good to me.
Thanks for fixing it Michal.
I'll just apply this directly, thanks everyone.