IB/mlx5: Protect against prefetch of invalid MR
authorMoni Shoua <monis@mellanox.com>
Sun, 17 Feb 2019 14:08:22 +0000 (16:08 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 21 Feb 2019 23:32:45 +0000 (16:32 -0700)
commita6bc3875f176f52c4a247c341e80d52dd4f5e356
treeaa4d817066c552e171be0bcc41fbc672c226fdd2
parent25fd08eb2be0fcebd5ab7bb8e1d4fe228c6739d0
IB/mlx5: Protect against prefetch of invalid MR

When deferring a prefetch request we need to protect against MR or PD
being destroyed while the request is still enqueued.

The first step is to validate that PD owns the lkey that describes the MR
and that the MR that the lkey refers to is owned by that PD.

The second step is to dequeue all requests when MR is destroyed.

Since PD can't be destroyed while it owns MRs it is guaranteed that when a
worker wakes up the request it refers to is still valid.

Now, it is possible to refrain from taking a reference on the device since
it is assured to be present as pd.

While that, replace the dedicated ordered workqueue with the system
unbound workqueue to reuse an existing resource and improve
performance. This will also fix a bug of queueing to the wrong workqueue.

Fixes: 813e90b1aeaa ("IB/mlx5: Add advise_mr() support")
Reported-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/mlx5/odp.c