linux_dsm_epyc7002/drivers/infiniband/hw/mlx5
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: 81713d3788 ("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
..
ah.c RDMA: Handle AH allocations by IB/core 2019-04-08 13:05:25 -03:00
cmd.c net/mlx5: Move device memory management to mlx5_core 2019-09-01 23:44:41 -07:00
cmd.h net/mlx5: Move device memory management to mlx5_core 2019-09-01 23:44:41 -07:00
cong.c infiniband: mlx5: no need to check return value of debugfs_create functions 2019-01-24 09:22:29 -07:00
cq.c Merge mlx5-next into rdma for-next 2019-07-03 16:50:26 -03:00
devx.c Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux 2019-08-28 11:48:56 -07:00
doorbell.c IB/{core,hw}: Have ib_umem_get extract the ib_ucontext from ib_udata 2019-01-10 17:07:45 -07:00
flow.c RDMA subsystem updates for 5.4 2019-09-21 10:26:24 -07:00
gsi.c RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const 2018-07-30 20:09:34 -06:00
ib_rep.c Merge mlx5-next into rdma for-next 2019-07-05 10:16:19 -03:00
ib_rep.h Merge mlx5-next into rdma for-next 2019-07-03 16:50:26 -03:00
ib_virt.c IB/mlx5: Restore IB guid/policy for virtual functions 2017-07-24 10:34:28 -04:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mad.c IB/mlx5: Fixed reporting counters on 2nd port for Dual port RoCE 2019-07-03 15:08:54 -03:00
main.c RDMA subsystem updates for 5.4 2019-09-21 10:26:24 -07:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mem.c RDMA/odp: Split creating a umem_odp from ib_umem_get 2019-08-21 14:08:42 -03:00
mlx5_ib.h RDMA subsystem updates for 5.4 2019-09-21 10:26:24 -07:00
mr.c RDMA/mlx5: Do not allow rereg of a ODP MR 2019-10-04 15:54:21 -03:00
odp.c RDMA/odp: Lift umem_mutex out of ib_umem_odp_unmap_dma_pages() 2019-10-04 15:54:21 -03:00
qp.c Merge tag 'v5.3-rc8' into rdma.git for-next 2019-09-13 16:59:51 -03:00
srq_cmd.c mlx5: Use refcount_t for refcount 2019-08-07 11:01:48 -07:00
srq.c RDMA: Handle SRQ allocations by IB/core 2019-04-08 13:05:25 -03:00
srq.h RDMA: Handle SRQ allocations by IB/core 2019-04-08 13:05:25 -03:00