Jason Gunthorpe 9dc775e7f5 RDMA/odp: Lift umem_mutex out of ib_umem_odp_unmap_dma_pages()
This fixes a race of the form:
    CPU0                               CPU1
mlx5_ib_invalidate_range()     mlx5_ib_invalidate_range()
				 // This one actually makes npages == 0
				 ib_umem_odp_unmap_dma_pages()
				 if (npages == 0 && !dying)
  // This one does nothing
  ib_umem_odp_unmap_dma_pages()
  if (npages == 0 && !dying)
     dying = 1;
                                    dying = 1;
				    schedule_work(&umem_odp->work);
     // Double schedule of the same work
     schedule_work(&umem_odp->work);  // BOOM

npages and dying must be read and written under the umem_mutex lock.

Since whenever ib_umem_odp_unmap_dma_pages() is called mlx5 must also call
mlx5_ib_update_xlt, and both need to be done in the same locking region,
hoist the lock out of unmap.

This avoids an expensive double critical section in
mlx5_ib_invalidate_range().

Fixes: 81713d3788d2 ("IB/mlx5: Add implicit MR support")
Link: https://lore.kernel.org/r/20191001153821.23621-4-jgg@ziepe.ca
Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
2019-10-04 15:54:21 -03:00
..
2019-10-01 12:11:50 -03:00
2019-08-20 13:27:53 -04:00
2019-05-03 10:56:56 -03:00
2019-06-28 21:18:23 -03:00
2018-12-12 07:40:16 -07:00
2016-03-03 10:20:25 -05:00
2019-04-25 12:27:11 -03:00
2018-12-12 07:40:16 -07:00
2016-03-03 10:20:25 -05:00
2019-09-21 10:26:24 -07:00
2019-09-21 10:26:24 -07:00
2019-06-28 21:18:23 -03:00
2019-06-28 21:18:23 -03:00
2019-04-25 12:27:11 -03:00