Skip to content

Commit afd1417

Browse files
yishaihjgunthorpe
authored andcommitted
IB/mlx5: Use direct mkey destroy command upon UMR unreg failure
Use a direct firmware command to destroy the mkey in case the unreg UMR operation has failed. This prevents a case that a mkey will leak out from the cache post a failure to be destroyed by a UMR WR. In case the MR cache limit didn't reach a call to add another entry to the cache instead of the destroyed one is issued. In addition, replaced a warn message to WARN_ON() as this flow is fatal and can't happen unless some bug around. Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> # 4.10 Fixes: 49780d4 ("IB/mlx5: Expose MR cache for mlx5_ib") Signed-off-by: Yishai Hadas <[email protected]> Reviewed-by: Artemy Kovalyov <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6a05395 commit afd1417

File tree

1 file changed

+8
-5
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+8
-5
lines changed

drivers/infiniband/hw/mlx5/mr.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,16 @@ void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
545545
return;
546546

547547
c = order2idx(dev, mr->order);
548-
if (c < 0 || c >= MAX_MR_CACHE_ENTRIES) {
549-
mlx5_ib_warn(dev, "order %d, cache index %d\n", mr->order, c);
550-
return;
551-
}
548+
WARN_ON(c < 0 || c >= MAX_MR_CACHE_ENTRIES);
552549

553-
if (unreg_umr(dev, mr))
550+
if (unreg_umr(dev, mr)) {
551+
mr->allocated_from_cache = false;
552+
destroy_mkey(dev, mr);
553+
ent = &cache->ent[c];
554+
if (ent->cur < ent->limit)
555+
queue_work(cache->wq, &ent->work);
554556
return;
557+
}
555558

556559
ent = &cache->ent[c];
557560
spin_lock_irq(&ent->lock);

0 commit comments

Comments
 (0)