Skip to content

Commit

Permalink
mlx5: Fix need_uuar_lock when there are no medium bfregs
Browse files Browse the repository at this point in the history
Fixes need_uuar_lock() to work properly even when there are no
medium bfregs. At that case bfreg entry 1 gets a wrong value, need lock
instead of not needing a lock.

The above case might happen only if the user uses the environment variable
'MLX5_NUM_LOW_LAT_UUARS' and sets it to be less than tot_uuars by 1,
leaving no available medium bfregs.

Fixes: 8c4791a ("libmlx5: First version of libmlx5")
Reported-by: Rohit Zambre <rzambre@uci.edu>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
  • Loading branch information
Eli Cohen authored and yishaih committed May 14, 2018
1 parent 6e5bfea commit e38d762
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion providers/mlx5/mlx5.c
Expand Up @@ -555,10 +555,13 @@ static int get_num_low_lat_uuars(int tot_uuars)
*/
static int need_uuar_lock(struct mlx5_context *ctx, int uuarn)
{
int i;

if (uuarn == 0 || mlx5_single_threaded)
return 0;

if (uuarn >= (ctx->tot_uuars - ctx->low_lat_uuars) * 2)
i = (uuarn / 2) + (uuarn % 2);
if (i >= ctx->tot_uuars - ctx->low_lat_uuars)
return 0;

return 1;
Expand Down

0 comments on commit e38d762

Please sign in to comment.