Doug writes: "RDMA fixes: Final for-rc pull request for 4.19 We only have one bug to submit this time around. It fixes a DMA unmap issue where we unmapped the DMA address from the IOMMU before we did from the card, resulting in a DMAR error with IOMMU enabled, or possible crash without." * tag 'for-gkh' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: IB/mlx5: Unmap DMA addr from HCA before IOMMU
Unified · Split
| @@ -544,6 +544,9 @@ void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) · 543 unmodified lines | ||
| 544 | 544 | int shrink = 0; |
| 545 | 545 | int c; |
| 546 | 546 | |
| 547 | + if (!mr->allocated_from_cache) | |
| 548 | + return; | |
| 549 | + | |
| 547 | 550 | c = order2idx(dev, mr->order); |
| 548 | 551 | if (c < 0 || c >= MAX_MR_CACHE_ENTRIES) { |
| 549 | 552 | mlx5_ib_warn(dev, "order %d, cache index %d\n", mr->order, c); |
| @@ -1647,18 +1650,19 @@ static void dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) · 1097 unmodified lines | ||
| 1647 | 1650 | umem = NULL; |
| 1648 | 1651 | } |
| 1649 | 1652 | #endif |
| 1650 | − | |
| 1651 | 1653 | clean_mr(dev, mr); |
| 1652 | 1654 | |
| 1655 | + /* | |
| 1656 | + * We should unregister the DMA address from the HCA before | |
| 1657 | + * remove the DMA mapping. | |
| 1658 | + */ | |
| 1659 | + mlx5_mr_cache_free(dev, mr); | |
| 1653 | 1660 | if (umem) { |
| 1654 | 1661 | ib_umem_release(umem); |
| 1655 | 1662 | atomic_sub(npages, &dev->mdev->priv.reg_pages); |
| 1656 | 1663 | } |
| 1657 | − | |
| 1658 | 1664 | if (!mr->allocated_from_cache) |
| 1659 | 1665 | kfree(mr); |
| 1660 | − else | |
| 1661 | − mlx5_mr_cache_free(dev, mr); | |
| 1662 | 1666 | } |
| 1663 | 1667 | |
| 1664 | 1668 | int mlx5_ib_dereg_mr(struct ib_mr *ibmr) |