[PATCH rdma-next 09/15] vfio/mlx5: Enable relaxed ordering on the live migration data mkey
From: Michael Gur
Date: Sun Jul 26 2026 - 05:35:39 EST
As firmware guarantees that all device-issued data writes complete before
posting of CQE, there is no need for strong ordering of memory accesses
on the live migration data mkey.
Enable relaxed ordering on the mkey via the mlx5_core RO setter.
This allows better performance and supporting vfio live migration on HW
that restricts memory registration with strict ordering.
Reviewed-by: Yishai Hadas <yishaih@xxxxxxxxxx>
Signed-off-by: Michael Gur <michaelgur@xxxxxxxxxx>
---
drivers/vfio/pci/mlx5/cmd.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/vfio/pci/mlx5/cmd.c b/drivers/vfio/pci/mlx5/cmd.c
index 5fe0621b5fbd..f534c27597bc 100644
--- a/drivers/vfio/pci/mlx5/cmd.c
+++ b/drivers/vfio/pci/mlx5/cmd.c
@@ -320,7 +320,7 @@ static int mlx5vf_cmd_get_vhca_id(struct mlx5_core_dev *mdev, u16 function_id,
return ret;
}
-static u32 *alloc_mkey_in(u32 npages, u32 pdn)
+static u32 *alloc_mkey_in(struct mlx5_core_dev *mdev, u32 npages, u32 pdn)
{
int inlen;
void *mkc;
@@ -348,6 +348,7 @@ static u32 *alloc_mkey_in(u32 npages, u32 pdn)
MLX5_SET(mkc, mkc, log_page_size, PAGE_SHIFT);
MLX5_SET(mkc, mkc, translations_octword_size, DIV_ROUND_UP(npages, 2));
MLX5_SET64(mkc, mkc, len, npages * PAGE_SIZE);
+ mlx5_core_mkey_set_relaxed_ordering(mdev, mkc);
return in;
}
@@ -439,7 +440,7 @@ static int mlx5vf_dma_data_buffer(struct mlx5_vhca_data_buffer *buf)
if (buf->mkey_in || !buf->npages)
return -EINVAL;
- buf->mkey_in = alloc_mkey_in(buf->npages, buf->migf->pdn);
+ buf->mkey_in = alloc_mkey_in(mdev, buf->npages, buf->migf->pdn);
if (!buf->mkey_in)
return -ENOMEM;
@@ -1439,7 +1440,7 @@ static int mlx5vf_alloc_qp_recv_resources(struct mlx5_core_dev *mdev,
recv_buf->npages = npages;
- recv_buf->mkey_in = alloc_mkey_in(npages, pdn);
+ recv_buf->mkey_in = alloc_mkey_in(mdev, npages, pdn);
if (!recv_buf->mkey_in) {
err = -ENOMEM;
goto end;
--
2.52.0