Commit 91b74bf5 authored by Alexander Lobakin's avatar Alexander Lobakin Committed by Jason Gunthorpe

IB/mlx5: Optimize u64 division on 32-bit arches

Commit f164be8c ("IB/mlx5: Extend caps stage to handle VAR
capabilities") introduced a straight "/" division of the u64 variable
"bar_size".

This was fixed with commit 685eff51 ("IB/mlx5: Use div64_u64 for
num_var_hw_entries calculation"). However, div64_u64() is redundant here
as mlx5_var_table::stride_size is of type u32.  Make the actual code way
more optimized on 32-bit kernels using div_u64() and fix 80 chars
break-through by the way.

Fixes: 685eff51 ("IB/mlx5: Use div64_u64 for num_var_hw_entries calculation")
Link: https://lore.kernel.org/r/20200217073629.8051-1-alobakin@dlink.ruSigned-off-by: default avatarAlexander Lobakin <alobakin@dlink.ru>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent c13cac2a
...@@ -6545,7 +6545,8 @@ static int mlx5_ib_init_var_table(struct mlx5_ib_dev *dev) ...@@ -6545,7 +6545,8 @@ static int mlx5_ib_init_var_table(struct mlx5_ib_dev *dev)
doorbell_bar_offset); doorbell_bar_offset);
bar_size = (1ULL << log_doorbell_bar_size) * 4096; bar_size = (1ULL << log_doorbell_bar_size) * 4096;
var_table->stride_size = 1ULL << log_doorbell_stride; var_table->stride_size = 1ULL << log_doorbell_stride;
var_table->num_var_hw_entries = div64_u64(bar_size, var_table->stride_size); var_table->num_var_hw_entries = div_u64(bar_size,
var_table->stride_size);
mutex_init(&var_table->bitmap_lock); mutex_init(&var_table->bitmap_lock);
var_table->bitmap = bitmap_zalloc(var_table->num_var_hw_entries, var_table->bitmap = bitmap_zalloc(var_table->num_var_hw_entries,
GFP_KERNEL); GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment