Skip to content

Commit 0b80c14

Browse files
Eli Cohenrleon
authored andcommitted
IB/mlx5: Fix retrieval of index to first hi class bfreg
First the function retrieving the index of the first hi latency class blue flame register. High latency class bfregs are located right above medium latency class bfregs. Fixes: c1be523 ('IB/mlx5: Fix micro UAR allocator') Signed-off-by: Eli Cohen <[email protected]> Reviewed-by: Matan Barak <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2f5ff26 commit 0b80c14

File tree

1 file changed

+14
-10
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+14
-10
lines changed

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,21 @@ static int next_bfreg(int n)
490490
return n;
491491
}
492492

493+
enum {
494+
/* this is the first blue flame register in the array of bfregs assigned
495+
* to a processes. Since we do not use it for blue flame but rather
496+
* regular 64 bit doorbells, we do not need a lock for maintaiing
497+
* "odd/even" order
498+
*/
499+
NUM_NON_BLUE_FLAME_BFREGS = 1,
500+
};
501+
493502
static int num_med_bfreg(struct mlx5_bfreg_info *bfregi)
494503
{
495504
int n;
496505

497506
n = bfregi->num_uars * MLX5_NON_FP_BFREGS_PER_UAR -
498-
bfregi->num_low_latency_bfregs - 1;
507+
bfregi->num_low_latency_bfregs - NUM_NON_BLUE_FLAME_BFREGS;
499508

500509
return n >= 0 ? n : 0;
501510
}
@@ -508,17 +517,9 @@ static int max_bfregi(struct mlx5_bfreg_info *bfregi)
508517
static int first_hi_bfreg(struct mlx5_bfreg_info *bfregi)
509518
{
510519
int med;
511-
int i;
512-
int t;
513520

514521
med = num_med_bfreg(bfregi);
515-
for (t = 0, i = first_med_bfreg();; i = next_bfreg(i)) {
516-
t++;
517-
if (t == med)
518-
return next_bfreg(i);
519-
}
520-
521-
return 0;
522+
return next_bfreg(med);
522523
}
523524

524525
static int alloc_high_class_bfreg(struct mlx5_bfreg_info *bfregi)
@@ -544,6 +545,8 @@ static int alloc_med_class_bfreg(struct mlx5_bfreg_info *bfregi)
544545
for (i = first_med_bfreg(); i < first_hi_bfreg(bfregi); i = next_bfreg(i)) {
545546
if (bfregi->count[i] < bfregi->count[minidx])
546547
minidx = i;
548+
if (!bfregi->count[minidx])
549+
break;
547550
}
548551

549552
bfregi->count[minidx]++;
@@ -558,6 +561,7 @@ static int alloc_bfreg(struct mlx5_bfreg_info *bfregi,
558561
mutex_lock(&bfregi->lock);
559562
switch (lat) {
560563
case MLX5_IB_LATENCY_CLASS_LOW:
564+
BUILD_BUG_ON(NUM_NON_BLUE_FLAME_BFREGS != 1);
561565
bfregn = 0;
562566
bfregi->count[bfregn]++;
563567
break;

0 commit comments

Comments
 (0)