mlx5: avoid 64-bit division in dr_icm_pool_mr_create()
authorMichal Kubecek <mkubecek@suse.cz>
Wed, 2 Oct 2019 12:12:41 +0000 (14:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Oct 2019 15:08:20 +0000 (11:08 -0400)
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.

Fixes: 29cf8febd185 ("net/mlx5: DR, ICM pool memory allocator")
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c

index 913f1e5aaaf2667c8130e5352f4ae8744a5b153e..d7c7467e2d53df0e7c0d2ba98d27f61df01703b2 100644 (file)
@@ -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;