RDMA: Support HW requiring relaxed ordering and add Unordered access flag
Subsystems (11)
cover RDMA: Support HW requiring relaxed ordering and add Unordered access flag
This series prepares the mlx5 stack for hardware that restricts strong- ordered memory accesses, i.e. HW whose fabric doesn't guarantee memory operation ordering. The HW may choose to reject creation of an mkey that doesn't request relaxed ordering, so every mkey the driver creates - internal and user-facing - has to be handled accordingly.
The previously added 'ConnectX-10 NVLink-C2C' PCI device is such a device, as will be any future PCIe Gen7 UIO devices.
The series does four things:
1. Allow optional access flags on all memory registration
The uverbs ABI defines the optional access flags range as best-effort:
drivers must accept any flag in this range and treat support as opportunistic, never failing registration. Several registration paths (DM, DEVX UMEM, dmabuf ioctl, reg_mr ioctl) did not allow this range and would reject such requests. These are fixed to allow newly added optional access flag added later in the series and any future optional access flag.
2. Groundwork and internal mkeys
Rename the relaxed-ordering IFC fields to the new naming, add the new ordering capability and mkey-context bits, and consolidate RO-setting to a single helper in mlx5_core so all consumers share one cap-gated implementation. Then enable relaxed ordering on the internal mkeys that don't require strong ordering (resource dump, vfio live-migration data, ODP null mkey, memory window mkey), so they keep working on strict-RO HW.
3. New Unordered access flag and enforcement
Add IB_ACCESS_UNORDERED, an optional access flag that additionally allows read-after-write reordering, and wire up mlx5 support for it.
4. Enforce no-strong-ordering in user MR registration on HW that requires it.
Michael Gur (15):
RDMA/mlx5: Allow optional access flags in DM registration RDMA/mlx5: Allow optional access flags in DEVX UMEM registration RDMA/core: Allow optional access flags in dmabuf reg ioctl RDMA/core: Allow optional access flags in reg mr ioctl
mlx5: Rename IFC bits of relaxed ordering fields
net/mlx5: Add IFC bits for new ordering caps
mlx5: Move RO setting helper to core and consolidate mlx5 consumers net/mlx5: Enable relaxed ordering on resource dump mkey vfio/mlx5: Enable relaxed ordering on the live migration data mkey RDMA/mlx5: Enable relaxed ordering on ODP null mkey RDMA/mlx5: Enable relaxed ordering on Memory Window mkey on strict-RO
HW
RDMA/mlx5: Converge UMR access-flag cap checks RDMA/uverbs: Add new Unordered MR access flag
RDMA/mlx5: Support new Unordered access flag
RDMA/mlx5: Enforce relaxed ordering when HW requires it
drivers/infiniband/core/umem.c | 2 +- drivers/infiniband/core/uverbs_std_types_mr.c | 4 +- drivers/infiniband/hw/mlx5/devx.c | 2 +- drivers/infiniband/hw/mlx5/main.c | 8 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 4 +- drivers/infiniband/hw/mlx5/mr.c | 79 ++++++++++--------- drivers/infiniband/hw/mlx5/odp.c | 1 + drivers/infiniband/hw/mlx5/umr.c | 18 ++--- drivers/infiniband/hw/mlx5/umr.h | 45 ++++++----- .../mellanox/mlx5/core/diag/rsc_dump.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 - .../ethernet/mellanox/mlx5/core/en/params.c | 2 +- .../ethernet/mellanox/mlx5/core/en_common.c | 13 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 21 +++++ drivers/vfio/pci/mlx5/cmd.c | 7 +- include/linux/mlx5/driver.h | 1 + include/linux/mlx5/mlx5_ifc.h | 24 ++++-- include/rdma/ib_verbs.h | 1 + include/uapi/rdma/ib_user_ioctl_verbs.h | 1 + 20 files changed, 134 insertions(+), 105 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/15 RDMA/mlx5: Allow optional access flags in DM registration
The uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.
Add the optional access flag to the allow-lists of DM registrations. Uverbs users can now request any optional access flag on DM registrations and mlx5 will apply the flag's effect on a best-effort basis when supported.
--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
@@ -660,11 +660,13 @@ struct mlx5_ib_mkey { IB_ACCESS_REMOTE_WRITE |\ IB_ACCESS_REMOTE_READ |\ IB_ACCESS_REMOTE_ATOMIC |\ + IB_ACCESS_OPTIONAL |\ IB_ZERO_BASED)#define MLX5_IB_DM_SW_ICM_ALLOWED_ACCESS (IB_ACCESS_LOCAL_WRITE |\ IB_ACCESS_REMOTE_WRITE |\ IB_ACCESS_REMOTE_READ |\ + IB_ACCESS_OPTIONAL |\ IB_ZERO_BASED)#define mlx5_update_odp_stats (mr, counter_name, value) \
Signature · 1 line
2.52.0
PATCH 2/15 RDMA/mlx5: Allow optional access flags in DEVX UMEM registration
In reply to Michael GurThe uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.
Add the optional access flag to the allow-list of DEVX UMEM registration. Uverbs users can now request any optional access flag on these registrations and mlx5 will apply the flag's effect on a best-effort basis when supported.
--- drivers/infiniband/hw/mlx5/devx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/devx.c +1 -1
@@ -2410,7 +2410,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_UMEM_REG)(IB_ACCESS_LOCAL_WRITE |IB_ACCESS_REMOTE_WRITE |IB_ACCESS_REMOTE_READ | - IB_ACCESS_RELAXED_ORDERING); + IB_ACCESS_OPTIONAL);if (err)return err;
Signature · 1 line
2.52.0
PATCH 3/15 RDMA/core: Allow optional access flags in dmabuf reg ioctl
In reply to Michael GurThe uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.
Add the optional access flag to the allow-list of dmabuf registration ioctl. Uverbs users can now request any optional access flag on dmabuf registrations and drivers will apply the flag's effect on a best-effort basis when supported.
--- drivers/infiniband/core/uverbs_std_types_mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_mr.c +1 -1
@@ -229,7 +229,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(IB_ACCESS_REMOTE_READ |IB_ACCESS_REMOTE_WRITE |IB_ACCESS_REMOTE_ATOMIC | - IB_ACCESS_RELAXED_ORDERING); + IB_ACCESS_OPTIONAL);if (ret)return ret;
Signature · 1 line
2.52.0
PATCH 4/15 RDMA/core: Allow optional access flags in reg mr ioctl
In reply to Michael GurThe uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.
Add the optional access flag to the allow-list of dmabuf registration through the reg_mr ioctl. Uverbs users can now request any optional access flag on dmabuf registrations and mlx5 will apply the flag's effect on a best-effort basis when supported.
--- drivers/infiniband/core/uverbs_std_types_mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_mr.c +1 -1
@@ -332,7 +332,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(IB_ACCESS_REMOTE_READ |IB_ACCESS_REMOTE_WRITE |IB_ACCESS_REMOTE_ATOMIC | -IB_ACCESS_RELAXED_ORDERING ; +IB_ACCESS_OPTIONAL ; }else {if (!has_addr || has_fd_offset)return -EINVAL ;
Signature · 1 line
2.52.0
PATCH 5/15 mlx5: Rename IFC bits of relaxed ordering fields
In reply to Michael GurAlign the IFC field names with the new naming:
- relaxed_ordering_write_umr -> order_write_after_write_umr (cap)
- relaxed_ordering_read_umr -> pci_relaxed_ordered_read_umr (cap)
- relaxed_ordering_write -> mkc_order_write_after_write_ro (cap)
- relaxed_ordering_write -> order_write_after_write (mkc)
- relaxed_ordering_read -> pci_relaxed_ordered_read (cap and mkc)
Update all references across drivers.
--- drivers/infiniband/hw/mlx5/main.c | 8 ++++---- drivers/infiniband/hw/mlx5/mr.c | 16 ++++++++-------- drivers/infiniband/hw/mlx5/umr.c | 14 +++++++------- drivers/infiniband/hw/mlx5/umr.h | 8 ++++---- .../net/ethernet/mellanox/mlx5/core/en/params.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_common.c | 8 ++++---- include/linux/mlx5/mlx5_ifc.h | 12 ++++++------ 7 files changed, 34 insertions(+), 34 deletions(-)
drivers/infiniband/hw/mlx5/main.c +4 -4
@@ -3513,13 +3513,13 @@ mlx5_ib_create_data_direct_resources(struct mlx5_ib_dev *dev) dev->ddr.pdn = pdn;/* create another mkey with RO support */ -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write)) { -MLX5_SET (mkc, mkc, relaxed_ordering_write,1 ); +if (MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro)) { +MLX5_SET (mkc, mkc, order_write_after_write,1 ); ro_supp = true; } -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read)) { -MLX5_SET (mkc, mkc, relaxed_ordering_read,1 ); +if (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read)) { +MLX5_SET (mkc, mkc, pci_relaxed_ordered_read,1 ); ro_supp = true; }
drivers/infiniband/hw/mlx5/mr.c +8 -8
@@ -72,14 +72,14 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,MLX5_SET (mkc, mkc, lr,1 );if (acc &IB_ACCESS_RELAXED_ORDERING ) { -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write)) -MLX5_SET (mkc, mkc, relaxed_ordering_write,1 ); +if (MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro)) +MLX5_SET (mkc, mkc, order_write_after_write,1 ); -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read) || +if (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) || (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_pci_enabled) &&pcie_relaxed_ordering_enabled (dev->mdev->pdev))) -MLX5_SET (mkc, mkc, relaxed_ordering_read,1 ); +MLX5_SET (mkc, mkc, pci_relaxed_ordered_read,1 ); }MLX5_SET (mkc, mkc, pd,to_mpd (pd)->pdn);
@@ -147,14 +147,14 @@ static int get_unchangeable_access_flags(struct mlx5_ib_dev *dev, ret |=IB_ACCESS_REMOTE_ATOMIC ;if ((access_flags &IB_ACCESS_RELAXED_ORDERING ) && -MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write) && - !MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write_umr)) +MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro) && + !MLX5_CAP_GEN (dev->mdev, order_write_after_write_umr)) ret |=IB_ACCESS_RELAXED_ORDERING ;if ((access_flags &IB_ACCESS_RELAXED_ORDERING ) && - (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read) || + (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) ||MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_pci_enabled)) && - !MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_umr)) + !MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read_umr)) ret |=IB_ACCESS_RELAXED_ORDERING ;return ret;
drivers/infiniband/hw/mlx5/umr.c +7 -7
@@ -59,10 +59,10 @@ static __be64 get_umr_update_access_mask(struct mlx5_ib_dev *dev)if (MLX5_CAP_GEN (dev->mdev, atomic)) result |=MLX5_MKEY_MASK_A ; -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write_umr)) +if (MLX5_CAP_GEN (dev->mdev, order_write_after_write_umr)) result |=MLX5_MKEY_MASK_RELAXED_ORDERING_WRITE ; -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_umr)) +if (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read_umr)) result |=MLX5_MKEY_MASK_RELAXED_ORDERING_READ ;return cpu_to_be64 (result);
@@ -88,11 +88,11 @@ static int umr_check_mkey_mask(struct mlx5_ib_dev *dev, u64 mask)return -EPERM ;if (mask &MLX5_MKEY_MASK_RELAXED_ORDERING_WRITE && - !MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write_umr)) + !MLX5_CAP_GEN (dev->mdev, order_write_after_write_umr))return -EPERM ;if (mask &MLX5_MKEY_MASK_RELAXED_ORDERING_READ && - !MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_umr)) + !MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read_umr))return -EPERM ;return 0 ;
@@ -446,7 +446,7 @@ static void mlx5r_umr_set_access_flags(struct mlx5_ib_dev *dev, unsigned int access_flags) {bool ro_read = (access_flags &IB_ACCESS_RELAXED_ORDERING ) && - (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read) || + (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) ||pcie_relaxed_ordering_enabled (dev->mdev->pdev));MLX5_SET (mkc, seg, a, !!(access_flags &IB_ACCESS_REMOTE_ATOMIC ));
@@ -454,9 +454,9 @@ static void mlx5r_umr_set_access_flags(struct mlx5_ib_dev *dev,MLX5_SET (mkc, seg, rr, !!(access_flags &IB_ACCESS_REMOTE_READ ));MLX5_SET (mkc, seg, lw, !!(access_flags &IB_ACCESS_LOCAL_WRITE ));MLX5_SET (mkc, seg, lr,1 ); -MLX5_SET (mkc, seg, relaxed_ordering_write, +MLX5_SET (mkc, seg, order_write_after_write, !!(access_flags &IB_ACCESS_RELAXED_ORDERING )); -MLX5_SET (mkc, seg, relaxed_ordering_read, ro_read); +MLX5_SET (mkc, seg, pci_relaxed_ordered_read, ro_read); } int mlx5r_umr_rereg_pd_access(struct mlx5_ib_mr *mr, struct ib_pd *pd,
drivers/infiniband/hw/mlx5/umr.h +4 -4
@@ -61,14 +61,14 @@ static inline bool mlx5r_umr_can_reconfig(struct mlx5_ib_dev *dev,return false;if ((diffs &IB_ACCESS_RELAXED_ORDERING ) && -MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write) && - !MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write_umr)) +MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro) && + !MLX5_CAP_GEN (dev->mdev, order_write_after_write_umr))return false;if ((diffs &IB_ACCESS_RELAXED_ORDERING ) && - (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read) || + (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) ||MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_pci_enabled)) && - !MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_umr)) + !MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read_umr))return false;return true;
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +1 -1
@@ -912,7 +912,7 @@ static void mlx5e_build_rx_cq_param(struct mlx5_core_dev *mdev,static u8 rq_end_pad_mode (struct mlx5_core_dev *mdev,struct mlx5e_params *params) {bool lro_en = params->packet_merge.type ==MLX5E_PACKET_MERGE_LRO ; -bool ro =MLX5_CAP_GEN (mdev, relaxed_ordering_write); +bool ro =MLX5_CAP_GEN (mdev, mkc_order_write_after_write_ro);return ro && lro_en ?MLX5_WQ_END_PAD_MODE_NONE :MLX5_WQ_END_PAD_MODE_ALIGN ;
drivers/net/ethernet/mellanox/mlx5/core/en_common.c +4 -4
@@ -40,13 +40,13 @@void mlx5e_mkey_set_relaxed_ordering (struct mlx5_core_dev *mdev,void *mkc) { -bool ro_write =MLX5_CAP_GEN (mdev, relaxed_ordering_write); -bool ro_read =MLX5_CAP_GEN (mdev, relaxed_ordering_read) || +bool ro_write =MLX5_CAP_GEN (mdev, mkc_order_write_after_write_ro); +bool ro_read =MLX5_CAP_GEN (mdev, pci_relaxed_ordered_read) || (pcie_relaxed_ordering_enabled (mdev->pdev) &&MLX5_CAP_GEN (mdev, relaxed_ordering_read_pci_enabled)); -MLX5_SET (mkc, mkc, relaxed_ordering_read, ro_read); -MLX5_SET (mkc, mkc, relaxed_ordering_write, ro_write); +MLX5_SET (mkc, mkc, pci_relaxed_ordered_read, ro_read); +MLX5_SET (mkc, mkc, order_write_after_write, ro_write); }int mlx5e_create_mkey (struct mlx5_core_dev *mdev,u32 pdn,u32 *mkey)
include/linux/mlx5/mlx5_ifc.h +6 -6
@@ -1709,15 +1709,15 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 max_sgl_for_optimized_performance[0x8 ];u8 log_max_cq_sz[0x8 ]; -u8 relaxed_ordering_write_umr[0x1 ]; -u8 relaxed_ordering_read_umr[0x1 ]; +u8 order_write_after_write_umr[0x1 ]; +u8 pci_relaxed_ordered_read_umr[0x1 ];u8 reserved_at_d2[0x7 ];u8 virtio_net_device_emualtion_manager[0x1 ];u8 virtio_blk_device_emualtion_manager[0x1 ];u8 log_max_cq[0x5 ];u8 log_max_eq_sz[0x8 ]; -u8 relaxed_ordering_write[0x1 ]; +u8 mkc_order_write_after_write_ro[0x1 ];u8 relaxed_ordering_read_pci_enabled[0x1 ];u8 log_max_mkey[0x6 ];u8 reserved_at_f0[0x6 ];
@@ -1949,7 +1949,7 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 reserved_at_320[0x3 ];u8 log_max_transport_domain[0x5 ];u8 reserved_at_328[0x2 ]; -u8 relaxed_ordering_read[0x1 ]; +u8 pci_relaxed_ordered_read[0x1 ];u8 log_max_pd[0x5 ];u8 dp_ordering_ooo_all_ud[0x1 ];u8 dp_ordering_ooo_all_uc[0x1 ];
@@ -4524,7 +4524,7 @@ struct mlx5_ifc_mkc_bits {u8 reserved_at_2[0x1 ];u8 access_mode_4_2[0x3 ];u8 reserved_at_6[0x7 ]; -u8 relaxed_ordering_write[0x1 ]; +u8 order_write_after_write[0x1 ];u8 reserved_at_e[0x1 ];u8 small_fence_on_rdma_read_response[0x1 ];u8 umr_en[0x1 ];
@@ -4566,7 +4566,7 @@ struct mlx5_ifc_mkc_bits {u8 translations_octword_size[0x20 ];u8 reserved_at_1c0[0x19 ]; -u8 relaxed_ordering_read[0x1 ]; +u8 pci_relaxed_ordered_read[0x1 ];u8 log_page_size[0x6 ];u8 reserved_at_1e0[0x5 ];
Signature · 1 line
2.52.0
PATCH 6/15 net/mlx5: Add IFC bits for new ordering caps
In reply to Michael GurAdd new HCA capability bits:
- mkc_order_read_after_write
- mkc_order_write_after_write_ro_only
Add new mkey context field:
- order_read_after_write (2-bit)
These fields enable a new level of memory access order relaxation, allowing read-after-write reordering and allow to expose an indication that devices don't support strict ordering of memory access.
--- include/linux/mlx5/mlx5_ifc.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
include/linux/mlx5/mlx5_ifc.h +10 -2
@@ -2003,7 +2003,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 roce_rw_supported[0x1 ];u8 log_max_current_uc_list_wr_supported[0x1 ];u8 log_max_stride_sz_rq[0x5 ]; -u8 reserved_at_3a8[0x3 ]; +u8 mkc_order_read_after_write[0x1 ]; +u8 mkc_order_write_after_write_ro_only[0x1 ]; +u8 reserved_at_3aa[0x1 ];u8 log_min_stride_sz_rq[0x5 ];u8 reserved_at_3b0[0x3 ];u8 log_max_stride_sz_sq[0x5 ];
@@ -4518,6 +4520,10 @@ enum { MLX5_MKC_PCIE_TPH_NO_STEERING_TAG_INDEX = 0, }; +enum { +MLX5_MKC_ORDER_READ_AFTER_WRITE_RO =1 , +}; +struct mlx5_ifc_mkc_bits {u8 reserved_at_0[0x1 ];u8 free[0x1 ];
@@ -4565,7 +4571,9 @@ struct mlx5_ifc_mkc_bits {u8 translations_octword_size[0x20 ]; -u8 reserved_at_1c0[0x19 ]; +u8 reserved_at_1c0[0x16 ]; +u8 order_read_after_write[0x2 ]; +u8 reserved_at_1d8[0x1 ];u8 pci_relaxed_ordered_read[0x1 ];u8 log_page_size[0x6 ];
Signature · 1 line
2.52.0
PATCH 7/15 mlx5: Move RO setting helper to core and consolidate mlx5 consumers
In reply to Michael GurMove mlx5e_mkey_set_relaxed_ordering() from en_common.c to core/mr.c as mlx5_core_mkey_set_relaxed_ordering() and export it. The helper centralizes the cap gating for order_write_after_write and pci_relaxed_ordered_read so each consumer no longer has to open-code the same dance.
Switch the static MR creation path (set_mkc_access_pd_addr_fields) and the UMR access-modify path (mlx5r_umr_set_access_flags) over to the new helper. Both call it inside the IB_ACCESS_RELAXED_ORDERING gate, preserving their existing conditional semantics: RO bits are only written when the caller actually requested RO. The Ethernet path already uses the helper unconditionally on every internal mkey it creates.
Consolidating onto the helper has two benefits beyond the deduplication itself:
* pcie_relaxed_ordering_enabled() is now invoked only when the caller requests RO, avoiding pci_lock contention on every MR registration.
* Reorder the inner AND so the cheap cap check short-circuits the slow pcie_relaxed_ordering_enabled() call on HW that lacks the relaxed_ordering_read_pci_enabled cap.
--- drivers/infiniband/hw/mlx5/mr.c | 12 ++--------- drivers/infiniband/hw/mlx5/umr.c | 10 +++------ drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 - .../ethernet/mellanox/mlx5/core/en_common.c | 13 +----------- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 21 +++++++++++++++++++ include/linux/mlx5/driver.h | 1 + 7 files changed, 30 insertions(+), 32 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +2 -10
@@ -71,16 +71,8 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,MLX5_SET (mkc, mkc, lw, !!(acc &IB_ACCESS_LOCAL_WRITE ));MLX5_SET (mkc, mkc, lr,1 ); -if (acc &IB_ACCESS_RELAXED_ORDERING ) { -if (MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro)) -MLX5_SET (mkc, mkc, order_write_after_write,1 ); - -if (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) || - (MLX5_CAP_GEN (dev->mdev, - relaxed_ordering_read_pci_enabled) && -pcie_relaxed_ordering_enabled (dev->mdev->pdev))) -MLX5_SET (mkc, mkc, pci_relaxed_ordered_read,1 ); - } +if (acc &IB_ACCESS_RELAXED_ORDERING ) +mlx5_core_mkey_set_relaxed_ordering (dev->mdev, mkc);MLX5_SET (mkc, mkc, pd,to_mpd (pd)->pdn);MLX5_SET (mkc, mkc, qpn,0xffffff );
drivers/infiniband/hw/mlx5/umr.c +3 -7
@@ -445,18 +445,14 @@ static void mlx5r_umr_set_access_flags(struct mlx5_ib_dev *dev,struct mlx5_mkey_seg *seg, unsigned int access_flags) { - bool ro_read = (access_flags & IB_ACCESS_RELAXED_ORDERING) && - (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) || -pcie_relaxed_ordering_enabled (dev->mdev->pdev)); - MLX5_SET(mkc, seg, a, !!(access_flags & IB_ACCESS_REMOTE_ATOMIC));MLX5_SET (mkc, seg, rw, !!(access_flags &IB_ACCESS_REMOTE_WRITE ));MLX5_SET (mkc, seg, rr, !!(access_flags &IB_ACCESS_REMOTE_READ ));MLX5_SET (mkc, seg, lw, !!(access_flags &IB_ACCESS_LOCAL_WRITE ));MLX5_SET (mkc, seg, lr,1 ); -MLX5_SET (mkc, seg, order_write_after_write, - !!(access_flags &IB_ACCESS_RELAXED_ORDERING )); -MLX5_SET (mkc, seg, pci_relaxed_ordered_read, ro_read); + +if (access_flags &IB_ACCESS_RELAXED_ORDERING ) +mlx5_core_mkey_set_relaxed_ordering (dev->mdev, seg); } int mlx5r_umr_rereg_pd_access(struct mlx5_ib_mr *mr, struct ib_pd *pd,
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -1
@@ -1192,7 +1192,6 @@ int mlx5e_modify_tirs_lb(struct mlx5_core_dev *mdev, bool enable_uc_lb, bool enable_mc_lb);int mlx5e_refresh_tirs (struct mlx5_core_dev *mdev,bool enable_uc_lb,bool enable_mc_lb); -void mlx5e_mkey_set_relaxed_ordering (struct mlx5_core_dev *mdev,void *mkc);/* common netdev helpers */ void mlx5e_create_q_counters (struct mlx5e_priv *priv);
drivers/net/ethernet/mellanox/mlx5/core/en_common.c +1 -12
@@ -38,17 +38,6 @@* Global resources are common to all the netdevices created on the same nic. */ -void mlx5e_mkey_set_relaxed_ordering (struct mlx5_core_dev *mdev,void *mkc) -{ -bool ro_write =MLX5_CAP_GEN (mdev, mkc_order_write_after_write_ro); -bool ro_read =MLX5_CAP_GEN (mdev, pci_relaxed_ordered_read) || - (pcie_relaxed_ordering_enabled (mdev->pdev) && -MLX5_CAP_GEN (mdev, relaxed_ordering_read_pci_enabled)); - -MLX5_SET (mkc, mkc, pci_relaxed_ordered_read, ro_read); -MLX5_SET (mkc, mkc, order_write_after_write, ro_write); -} -int mlx5e_create_mkey (struct mlx5_core_dev *mdev,u32 pdn,u32 *mkey) {int inlen =MLX5_ST_SZ_BYTES (create_mkey_in);
@@ -64,7 +53,7 @@ int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, u32 *mkey)MLX5_SET (mkc, mkc, access_mode_1_0,MLX5_MKC_ACCESS_MODE_PA );MLX5_SET (mkc, mkc, lw,1 );MLX5_SET (mkc, mkc, lr,1 ); -mlx5e_mkey_set_relaxed_ordering (mdev, mkc); +mlx5_core_mkey_set_relaxed_ordering (mdev, mkc);MLX5_SET (mkc, mkc, pd, pdn);MLX5_SET (mkc, mkc, length64,1 );MLX5_SET (mkc, mkc, qpn,0xffffff );
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -462,7 +462,7 @@ static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev,MLX5_SET (mkc, mkc, lw,1 );MLX5_SET (mkc, mkc, lr,1 );MLX5_SET (mkc, mkc, access_mode_1_0,mlx5e_mpwrq_access_mode (umr_mode)); -mlx5e_mkey_set_relaxed_ordering (mdev, mkc); +mlx5_core_mkey_set_relaxed_ordering (mdev, mkc);MLX5_SET (mkc, mkc, qpn,0xffffff );MLX5_SET (mkc, mkc, pd, mdev->mlx5e_res.hw_objs.pdn);MLX5_SET64 (mkc, mkc, len, npages << page_shift);
@@ -801,7 +801,7 @@ static int mlx5e_create_rq_hd_mkey(struct mlx5_core_dev *mdev,MLX5_SET (mkc, mkc, lw,1 );MLX5_SET (mkc, mkc, lr,1 );MLX5_SET (mkc, mkc, access_mode_1_0,MLX5_MKC_ACCESS_MODE_MTT ); -mlx5e_mkey_set_relaxed_ordering (mdev, mkc); +mlx5_core_mkey_set_relaxed_ordering (mdev, mkc);MLX5_SET (mkc, mkc, qpn,0xffffff );MLX5_SET (mkc, mkc, pd, mdev->mlx5e_res.hw_objs.pdn);MLX5_SET64 (mkc, mkc, len, shampo->hd_buf_size);
drivers/net/ethernet/mellanox/mlx5/core/mr.c +21 -0
@@ -35,6 +35,27 @@#include <linux/mlx5/qp.h> #include "mlx5_core.h" +/** +* mlx5_core_mkey_set_relaxed_ordering - Set RO flags in mkey context +* @dev: MLX5 core device +* @mkc: Memory key context buffer +* +* Sets order_write_after_write and pci_relaxed_ordered_read in @mkc +* based on device caps. Call when creating or modifying a memory key to have +* relaxed ordering. +*/ +void mlx5_core_mkey_set_relaxed_ordering (struct mlx5_core_dev *dev,void *mkc) +{ +bool ro_write =MLX5_CAP_GEN (dev, mkc_order_write_after_write_ro); +bool ro_read =MLX5_CAP_GEN (dev, pci_relaxed_ordered_read) || + (MLX5_CAP_GEN (dev, relaxed_ordering_read_pci_enabled) && +pcie_relaxed_ordering_enabled (dev->pdev)); + +MLX5_SET (mkc, mkc, pci_relaxed_ordered_read, ro_read); +MLX5_SET (mkc, mkc, order_write_after_write, ro_write); +} +EXPORT_SYMBOL (mlx5_core_mkey_set_relaxed_ordering); +int mlx5_core_create_mkey (struct mlx5_core_dev *dev,u32 *mkey,u32 *in,int inlen) {
include/linux/mlx5/driver.h +1 -0
@@ -1035,6 +1035,7 @@ void mlx5_trigger_health_work(struct mlx5_core_dev *dev);int mlx5_frag_buf_alloc_node (struct mlx5_core_dev *dev,int size,struct mlx5_frag_buf *buf,int node);void mlx5_frag_buf_free (struct mlx5_core_dev *dev,struct mlx5_frag_buf *buf); +void mlx5_core_mkey_set_relaxed_ordering (struct mlx5_core_dev *dev,void *mkc);int mlx5_core_create_mkey (struct mlx5_core_dev *dev,u32 *mkey,u32 *in,int inlen);int mlx5_core_destroy_mkey (struct mlx5_core_dev *dev,u32 mkey);
Signature · 1 line
2.52.0
PATCH 8/15 net/mlx5: Enable relaxed ordering on resource dump mkey
In reply to Michael GurAs resource dump logic reads data only following an event that is delivered with strong ordering, there is no need for strong ordering of its memory accesses.
Add relaxed ordering access flag to its registered memory, thus allowing better performance and allowing resource dump on HW that restricts strong ordering.
--- drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.c +1 -0
@@ -236,6 +236,7 @@ static int mlx5_rsc_dump_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,MLX5_SET (mkc, mkc, access_mode_1_0,MLX5_MKC_ACCESS_MODE_PA );MLX5_SET (mkc, mkc, lw,1 );MLX5_SET (mkc, mkc, lr,1 ); +mlx5_core_mkey_set_relaxed_ordering (mdev, mkc);MLX5_SET (mkc, mkc, pd, pdn);MLX5_SET (mkc, mkc, length64,1 );
Signature · 1 line
2.52.0
PATCH 9/15 vfio/mlx5: Enable relaxed ordering on the live migration data mkey
In reply to Michael GurAs 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.
--- drivers/vfio/pci/mlx5/cmd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vfio/pci/mlx5/cmd.c +4 -3
@@ -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;
Signature · 1 line
2.52.0
PATCH 10/15 RDMA/mlx5: Enable relaxed ordering on ODP null mkey
In reply to Michael GurEnable relaxed ordering on the ODP implicit-MR null mkey. This allows supporting implicit ODP on HW that restricts memory registration with strict ordering.
No functional change as this is a null mkey with no memory mappings.
--- drivers/infiniband/hw/mlx5/odp.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/odp.c +1 -0
@@ -579,6 +579,7 @@ static int alloc_implicit_mr_null_mkey(struct mlx5_ib_dev *dev,MLX5_SET (mkc, mkc, rr,1 );MLX5_SET (mkc, mkc, lw,1 );MLX5_SET (mkc, mkc, lr,1 ); +mlx5_core_mkey_set_relaxed_ordering (dev->mdev, mkc);MLX5_SET (mkc, mkc, free,0 );MLX5_SET (mkc, mkc, umr_en,0 );MLX5_SET (mkc, mkc, access_mode_1_0,MLX5_MKC_ACCESS_MODE_MTT );
Signature · 1 line
2.52.0
PATCH 11/15 RDMA/mlx5: Enable relaxed ordering on Memory Window mkey on strict-RO HW
In reply to Michael GurOn hardware that restricts strong-ordering access for memory registrations, set relaxed ordering on MW mkeys. Without this change, MW allocation mkey creation fails on such HW.
Enabling RO implicitly for users in this case is acceptable since all users share the same memory registration restriction, so any MR bound to this MW is guaranteed to have relaxed ordering as well.
--- drivers/infiniband/hw/mlx5/mr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/mlx5/mr.c +3 -0
@@ -1822,6 +1822,9 @@ int mlx5_ib_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)MLX5_SET (mkc, mkc, en_rinval, !!((ibmw->type ==IB_MW_TYPE_2 )));MLX5_SET (mkc, mkc, qpn,0xffffff ); +if (MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro_only)) +mlx5_core_mkey_set_relaxed_ordering (dev->mdev, mkc); + err =mlx5_ib_create_mkey (dev, &mw->mmkey, in, inlen);if (err) goto free;
Signature · 1 line
2.52.0
PATCH 12/15 RDMA/mlx5: Converge UMR access-flag cap checks
In reply to Michael GurMove the UMR cap check from both MR registration and UMR paths to a single helper checking the access flags non-modifiable by UMR.
No behavior change for the current flag set.
Converge to prevent code duplication when adding support to new access flags that are not modifiable by UMR, like the new Unordered access flag added in following patches.
--- drivers/infiniband/hw/mlx5/mr.c | 30 +++----------------------- drivers/infiniband/hw/mlx5/umr.h | 37 ++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 43 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +3 -27
@@ -128,30 +128,6 @@ static int get_mkc_octo_size(unsigned int access_mode, unsigned int ndescs)return ret; } -static int get_unchangeable_access_flags (struct mlx5_ib_dev *dev, -int access_flags) -{ -int ret =0 ; - -if ((access_flags &IB_ACCESS_REMOTE_ATOMIC ) && -MLX5_CAP_GEN (dev->mdev, atomic) && -MLX5_CAP_GEN (dev->mdev, umr_modify_atomic_disabled)) - ret |=IB_ACCESS_REMOTE_ATOMIC ; - -if ((access_flags &IB_ACCESS_RELAXED_ORDERING ) && -MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro) && - !MLX5_CAP_GEN (dev->mdev, order_write_after_write_umr)) - ret |=IB_ACCESS_RELAXED_ORDERING ; - -if ((access_flags &IB_ACCESS_RELAXED_ORDERING ) && - (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) || -MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_pci_enabled)) && - !MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read_umr)) - ret |=IB_ACCESS_RELAXED_ORDERING ; - -return ret; -} -#define MLX5_FRMR_POOLS_KEY_ACCESS_MODE_KSM_MASK 1ULL#define MLX5_FRMR_POOLS_KEY_VENDOR_KEY_SUPPORTED \ MLX5_FRMR_POOLS_KEY_ACCESS_MODE_KSM_MASK
@@ -173,7 +149,7 @@ _mlx5_frmr_pool_alloc(struct mlx5_ib_dev *dev, struct ib_umem *umem, mr->ibmr.frmr.key.ats =mlx5_umem_needs_ats (dev, umem, access_flags); mr->ibmr.frmr.key.access_flags = -get_unchangeable_access_flags (dev, access_flags); +mlx5r_umr_get_unchangeable_access_flags (dev, access_flags); mr->ibmr.frmr.key.num_dma_blocks =ib_umem_num_dma_blocks (umem, page_size); mr->ibmr.frmr.key.vendor_key =
@@ -205,7 +181,7 @@ struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, {struct ib_frmr_key key = { .access_flags = -get_unchangeable_access_flags (dev, access_flags), +mlx5r_umr_get_unchangeable_access_flags (dev, access_flags), .vendor_key = access_mode ==MLX5_MKC_ACCESS_MODE_MTT ?0 :MLX5_FRMR_POOLS_KEY_ACCESS_MODE_KSM_MASK ,
@@ -324,7 +300,7 @@ static int mlx5r_build_frmr_key(struct ib_device *device, out->ats = in->ats; out->access_flags = -get_unchangeable_access_flags (dev, in->access_flags); +mlx5r_umr_get_unchangeable_access_flags (dev, in->access_flags); out->vendor_key = in->vendor_key; out->num_dma_blocks = in->num_dma_blocks;
drivers/infiniband/hw/mlx5/umr.h +21 -16
@@ -44,34 +44,39 @@ static inline bool mlx5r_umr_can_load_pas(struct mlx5_ib_dev *dev,return true; } -/* -* true if an existing MR can be reconfigured to new access_flags using UMR. -* Older HW cannot use UMR to update certain elements of the MKC. See -* get_umr_update_access_mask() and umr_check_mkey_mask() -*/ -static inline bool mlx5r_umr_can_reconfig (struct mlx5_ib_dev *dev, -unsigned int current_access_flags, -unsigned int target_access_flags) +/* Return subset of access_flags whose mkey fields can't be updated via UMR. */ +static inline unsigned int +mlx5r_umr_get_unchangeable_access_flags (struct mlx5_ib_dev *dev, +unsigned int access_flags) { -unsigned int diffs = current_access_flags ^ target_access_flags; +unsigned int ret =0 ; -if ((diffs &IB_ACCESS_REMOTE_ATOMIC ) && +if ((access_flags &IB_ACCESS_REMOTE_ATOMIC ) &&MLX5_CAP_GEN (dev->mdev, atomic) &&MLX5_CAP_GEN (dev->mdev, umr_modify_atomic_disabled)) -return false; + ret |=IB_ACCESS_REMOTE_ATOMIC ; -if ((diffs &IB_ACCESS_RELAXED_ORDERING ) && +if ((access_flags &IB_ACCESS_RELAXED_ORDERING ) &&MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro) && !MLX5_CAP_GEN (dev->mdev, order_write_after_write_umr)) -return false; + ret |=IB_ACCESS_RELAXED_ORDERING ; -if ((diffs &IB_ACCESS_RELAXED_ORDERING ) && +if ((access_flags &IB_ACCESS_RELAXED_ORDERING ) && (MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read) ||MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read_pci_enabled)) && !MLX5_CAP_GEN (dev->mdev, pci_relaxed_ordered_read_umr)) -return false; + ret |=IB_ACCESS_RELAXED_ORDERING ; -return true; +return ret; +} + +/* true if an existing MR can be reconfigured to new access_flags using UMR. */ +static inline bool mlx5r_umr_can_reconfig (struct mlx5_ib_dev *dev, +unsigned int current_access_flags, +unsigned int target_access_flags) +{ +return mlx5r_umr_get_unchangeable_access_flags ( + dev, current_access_flags ^ target_access_flags) ==0 ; }static inline u64 mlx5r_umr_get_xlt_octo (u64 bytes)
Signature · 1 line
2.52.0
PATCH 13/15 RDMA/uverbs: Add new Unordered MR access flag
In reply to Michael GurAdd a new Unordered access flag for MR registrations.
This access flag allows additional relaxing of the order of memory accesses to the memory region.
Using this access flag allows for concurrent reads and writes of this MR to be reordered.
This access flag is part of the optional access flags range, drivers shouldn't fail registration for any value in this range and are expected to treat them as best-effort.
--- drivers/infiniband/core/umem.c | 2 +- include/rdma/ib_verbs.h | 1 + include/uapi/rdma/ib_user_ioctl_verbs.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/umem.c +1 -1
@@ -204,7 +204,7 @@ static struct ib_umem *__ib_umem_get_va(struct ib_device *device, umem->writable =ib_access_writable (access); umem->owning_mm = mm = current->mm; umem->dma_attrs =DMA_ATTR_REQUIRE_COHERENT ; -if (access &IB_ACCESS_RELAXED_ORDERING ) +if (access & (IB_ACCESS_RELAXED_ORDERING |IB_ACCESS_UNORDERED )) umem->dma_attrs |=DMA_ATTR_WEAK_ORDERING ;mmgrab (mm);
include/rdma/ib_verbs.h +1 -0
@@ -1505,6 +1505,7 @@ enum ib_access_flags {IB_ACCESS_ON_DEMAND =IB_UVERBS_ACCESS_ON_DEMAND ,IB_ACCESS_HUGETLB =IB_UVERBS_ACCESS_HUGETLB ,IB_ACCESS_RELAXED_ORDERING =IB_UVERBS_ACCESS_RELAXED_ORDERING , +IB_ACCESS_UNORDERED =IB_UVERBS_ACCESS_UNORDERED ,IB_ACCESS_FLUSH_GLOBAL =IB_UVERBS_ACCESS_FLUSH_GLOBAL , IB_ACCESS_FLUSH_PERSISTENT = IB_UVERBS_ACCESS_FLUSH_PERSISTENT,
include/uapi/rdma/ib_user_ioctl_verbs.h +1 -0
@@ -62,6 +62,7 @@ enum ib_uverbs_access_flags {IB_UVERBS_ACCESS_FLUSH_PERSISTENT =1 <<9 ,IB_UVERBS_ACCESS_RELAXED_ORDERING =IB_UVERBS_ACCESS_OPTIONAL_FIRST , +IB_UVERBS_ACCESS_UNORDERED =IB_UVERBS_ACCESS_OPTIONAL_FIRST <<1 ,IB_UVERBS_ACCESS_OPTIONAL_RANGE = ((IB_UVERBS_ACCESS_OPTIONAL_LAST <<1 ) -1 ) & ~(IB_UVERBS_ACCESS_OPTIONAL_FIRST -1 )
Signature · 1 line
2.52.0
PATCH 14/15 RDMA/mlx5: Support new Unordered access flag
In reply to Michael GurAdd mlx5 driver support for IB_ACCESS_UNORDERED, the new uverbs access flag that enables relaxing the order of read after write on mkeys.
Extend the current enablement of ATS over DMABUF with RO access to also enable for DMABUF with Unordered access.
Mark IB_ACCESS_UNORDERED as non-UMR-modifiable: there is no UMR mkey-mask bit for order_read_after_write, so UMR cannot drive it.
--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 +- drivers/infiniband/hw/mlx5/mr.c | 7 ++++++- drivers/infiniband/hw/mlx5/umr.c | 2 +- drivers/infiniband/hw/mlx5/umr.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -1
@@ -1679,7 +1679,7 @@ static inline bool mlx5_umem_needs_ats(struct mlx5_ib_dev *dev, {if (!MLX5_CAP_GEN (dev->mdev, ats) || !umem->is_dmabuf)return false; -return access_flags &IB_ACCESS_RELAXED_ORDERING ; +return access_flags & (IB_ACCESS_RELAXED_ORDERING |IB_ACCESS_UNORDERED ); } int set_roce_addr(struct mlx5_ib_dev *dev, u32 port_num,
drivers/infiniband/hw/mlx5/mr.c +6 -1
@@ -71,9 +71,14 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,MLX5_SET (mkc, mkc, lw, !!(acc &IB_ACCESS_LOCAL_WRITE ));MLX5_SET (mkc, mkc, lr,1 ); -if (acc &IB_ACCESS_RELAXED_ORDERING ) +if (acc & (IB_ACCESS_RELAXED_ORDERING |IB_ACCESS_UNORDERED ))mlx5_core_mkey_set_relaxed_ordering (dev->mdev, mkc); +if ((acc &IB_ACCESS_UNORDERED ) && +MLX5_CAP_GEN (dev->mdev, mkc_order_read_after_write)) +MLX5_SET (mkc, mkc, order_read_after_write, +MLX5_MKC_ORDER_READ_AFTER_WRITE_RO ); +MLX5_SET (mkc, mkc, pd,to_mpd (pd)->pdn);MLX5_SET (mkc, mkc, qpn,0xffffff );MLX5_SET64 (mkc, mkc, start_addr, start_addr);
drivers/infiniband/hw/mlx5/umr.c +1 -1
@@ -451,7 +451,7 @@ static void mlx5r_umr_set_access_flags(struct mlx5_ib_dev *dev,MLX5_SET (mkc, seg, lw, !!(access_flags &IB_ACCESS_LOCAL_WRITE ));MLX5_SET (mkc, seg, lr,1 ); -if (access_flags &IB_ACCESS_RELAXED_ORDERING ) +if (access_flags & (IB_ACCESS_RELAXED_ORDERING |IB_ACCESS_UNORDERED ))mlx5_core_mkey_set_relaxed_ordering (dev->mdev, seg); }
drivers/infiniband/hw/mlx5/umr.h +1 -1
@@ -49,7 +49,7 @@ static inline unsigned int mlx5r_umr_get_unchangeable_access_flags(struct mlx5_ib_dev *dev, unsigned int access_flags) { - unsigned int ret = 0; + unsigned int ret = access_flags & IB_ACCESS_UNORDERED; if ((access_flags & IB_ACCESS_REMOTE_ATOMIC) && MLX5_CAP_GEN(dev->mdev, atomic) &&
Signature · 1 line
2.52.0
PATCH 15/15 RDMA/mlx5: Enforce relaxed ordering when HW requires it
In reply to Michael GurAdd relaxed ordering validation (relaxed or unordered) to enforce no strong ordered mkeys are created when the HW disallows it. Reject MR registrations that do not request IB_ACCESS_RELAXED_ORDERING or IB_ACCESS_UNORDERED.
Invoke the validator from all user-facing MR registration paths, including the Device Memory path (mlx5_ib_reg_dm_mr).
--- drivers/infiniband/hw/mlx5/mr.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mr.c +28 -1
@@ -84,6 +84,16 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,MLX5_SET64 (mkc, mkc, start_addr, start_addr); } +static int validate_ordering_access (struct mlx5_ib_dev *dev,int acc) +{ +/* If HW disallows Strong Ordered writes, RO/UNORDERED must be set */ +if (MLX5_CAP_GEN (dev->mdev, mkc_order_write_after_write_ro_only)) { +if (!(acc & (IB_ACCESS_RELAXED_ORDERING |IB_ACCESS_UNORDERED ))) +return -EOPNOTSUPP ; + } +return 0 ; +} +static void assign_mkey_variant (struct mlx5_ib_dev *dev,u32 *mkey,u32 *in) {u8 key =atomic_inc_return (&dev->mkey_var);
@@ -679,8 +689,13 @@ struct ib_mr *mlx5_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm, {struct mlx5_ib_dm *mdm =to_mdm (dm);struct mlx5_core_dev *dev =to_mdev (dm->device)->mdev; +struct mlx5_ib_dev *ib_dev =to_mdev (dm->device);u64 start_addr = mdm->dev_addr + attr->offset; -int mode; +int mode, err; + + err =validate_ordering_access (ib_dev, attr->access_flags); +if (err) +return ERR_PTR (err);switch (mdm->type) {case MLX5_IB_UAPI_DM_TYPE_MEMIC :
@@ -843,6 +858,10 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,mlx5_ib_dbg (dev,"start 0x%llx, iova 0x%llx, length 0x%llx, access_flags 0x%x\n" , start, iova, length, access_flags); + err =validate_ordering_access (dev, access_flags); +if (err) +return ERR_PTR (err); + err =mlx5r_umr_resource_init (dev);if (err)return ERR_PTR (err);
@@ -1034,6 +1053,10 @@ struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 offset,"offset 0x%llx, virt_addr 0x%llx, length 0x%llx, fd %d, access_flags 0x%x, mlx5_access_flags 0x%x\n" , offset, virt_addr, length, fd, access_flags, mlx5_access_flags); + err =validate_ordering_access (dev, access_flags); +if (err) +return ERR_PTR (err); +/* dmabuf requires xlt update via umr to work. */ if (!mlx5r_umr_can_load_pas (dev, length))return ERR_PTR (-EINVAL );
@@ -1167,6 +1190,10 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,if (!(flags &IB_MR_REREG_PD )) new_pd = ib_mr->pd; + err =validate_ordering_access (dev, new_access_flags); +if (err) +return ERR_PTR (err); +if (mr->is_odp_implicit && !(flags &IB_MR_REREG_TRANS )) {if (!(new_access_flags &IB_ACCESS_ON_DEMAND ))return ERR_PTR (-EOPNOTSUPP );
Signature · 1 line
2.52.0
Quoted 67 lines · Michael Gur
This series prepares the mlx5 stack for hardware that restricts strong- ordered memory accesses, i.e. HW whose fabric doesn't guarantee memory operation ordering. The HW may choose to reject creation of an mkey that doesn't request relaxed ordering, so every mkey the driver creates - internal and user-facing - has to be handled accordingly.
The previously added 'ConnectX-10 NVLink-C2C' PCI device is such a device, as will be any future PCIe Gen7 UIO devices.
The series does four things:
1. Allow optional access flags on all memory registration
The uverbs ABI defines the optional access flags range as best-effort:
drivers must accept any flag in this range and treat support as opportunistic, never failing registration. Several registration paths (DM, DEVX UMEM, dmabuf ioctl,reg_mrioctl) did not allow this range and would reject such requests. These are fixed to allow newly added optional access flag added later in the series and any future optional access flag.2. Groundwork and internal mkeys
Rename the relaxed-ordering IFC fields to the new naming, add the new ordering capability and mkey-context bits, and consolidate RO-setting to a single helper inmlx5_coreso all consumers share one cap-gated implementation. Then enable relaxed ordering on the internal mkeys that don't require strong ordering (resource dump, vfio live-migration data, ODP null mkey, memory window mkey), so they keep working on strict-RO HW.3. New Unordered access flag and enforcement
AddIB_ACCESS_UNORDERED, an optional access flag that additionally allows read-after-write reordering, and wire up mlx5 support for it.4. Enforce no-strong-ordering in user MR registration on HW that requires it.
Michael Gur (15):
RDMA/mlx5: Allow optional access flags in DM registration RDMA/mlx5: Allow optional access flags in DEVX UMEM registration RDMA/core: Allow optional access flags in dmabuf reg ioctl RDMA/core: Allow optional access flags in reg mr ioctl
mlx5: Rename IFC bits of relaxed ordering fields
net/mlx5: Add IFC bits for new ordering caps
mlx5: Move RO setting helper to core and consolidate mlx5 consumers net/mlx5: Enable relaxed ordering on resource dump mkey vfio/mlx5: Enable relaxed ordering on the live migration data mkey RDMA/mlx5: Enable relaxed ordering on ODP null mkey RDMA/mlx5: Enable relaxed ordering on Memory Window mkey on strict-RO
HW
RDMA/mlx5: Converge UMR access-flag cap checks RDMA/uverbs: Add new Unordered MR access flag
RDMA/mlx5: Support new Unordered access flag
RDMA/mlx5: Enforce relaxed ordering when HW requires itdrivers/infiniband/core/umem.c | 2 +- drivers/infiniband/core/uverbs_std_types_mr.c | 4 +- drivers/infiniband/hw/mlx5/devx.c | 2 +- drivers/infiniband/hw/mlx5/main.c | 8 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 4 +- drivers/infiniband/hw/mlx5/mr.c | 79 ++++++++++--------- drivers/infiniband/hw/mlx5/odp.c | 1 + drivers/infiniband/hw/mlx5/umr.c | 18 ++--- drivers/infiniband/hw/mlx5/umr.h | 45 ++++++----- .../mellanox/mlx5/core/diag/rsc_dump.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 - .../ethernet/mellanox/mlx5/core/en/params.c | 2 +- .../ethernet/mellanox/mlx5/core/en_common.c | 13 +--
Quoted 8 lines
.../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 21 +++++ drivers/vfio/pci/mlx5/cmd.c | 7 +- include/linux/mlx5/driver.h | 1 + include/linux/mlx5/mlx5_ifc.h | 24 ++++-- include/rdma/ib_verbs.h | 1 + include/uapi/rdma/ib_user_ioctl_verbs.h | 1 + 20 files changed, 134 insertions(+), 105 deletions(-)
Sashiko is not happy about this series.
Thanks
Quoted 4 lines
Signature · 2 lines
-- 2.52.0
Quoted 79 lines · Leon Romanovsky
External email: Use caution opening links or attachments
Quoted 67 lines · Michael Gur
This series prepares the mlx5 stack for hardware that restricts strong- ordered memory accesses, i.e. HW whose fabric doesn't guarantee memory operation ordering. The HW may choose to reject creation of an mkey that doesn't request relaxed ordering, so every mkey the driver creates - internal and user-facing - has to be handled accordingly.
The previously added 'ConnectX-10 NVLink-C2C' PCI device is such a device, as will be any future PCIe Gen7 UIO devices.
The series does four things:
1. Allow optional access flags on all memory registration
The uverbs ABI defines the optional access flags range as best-effort:
drivers must accept any flag in this range and treat support as opportunistic, never failing registration. Several registration paths (DM, DEVX UMEM, dmabuf ioctl,reg_mrioctl) did not allow this range and would reject such requests. These are fixed to allow newly added optional access flag added later in the series and any future optional access flag.2. Groundwork and internal mkeys
Rename the relaxed-ordering IFC fields to the new naming, add the new ordering capability and mkey-context bits, and consolidate RO-setting to a single helper inmlx5_coreso all consumers share one cap-gated implementation. Then enable relaxed ordering on the internal mkeys that don't require strong ordering (resource dump, vfio live-migration data, ODP null mkey, memory window mkey), so they keep working on strict-RO HW.3. New Unordered access flag and enforcement
AddIB_ACCESS_UNORDERED, an optional access flag that additionally allows read-after-write reordering, and wire up mlx5 support for it.4. Enforce no-strong-ordering in user MR registration on HW that requires
it.Michael Gur (15):
RDMA/mlx5: Allow optional access flags in DM registration RDMA/mlx5: Allow optional access flags in DEVX UMEM registration RDMA/core: Allow optional access flags in dmabuf reg ioctl RDMA/core: Allow optional access flags in reg mr ioctl
mlx5: Rename IFC bits of relaxed ordering fields net/mlx5: Add IFC bits for new ordering caps
mlx5: Move RO setting helper to core and consolidate mlx5 consumers net/mlx5: Enable relaxed ordering on resource dump mkey vfio/mlx5: Enable relaxed ordering on the live migration data mkey RDMA/mlx5: Enable relaxed ordering on ODP null mkey RDMA/mlx5: Enable relaxed ordering on Memory Window mkey on strict-RO
HW
RDMA/mlx5: Converge UMR access-flag cap checks RDMA/uverbs: Add new Unordered MR access flag
RDMA/mlx5: Support new Unordered access flag
RDMA/mlx5: Enforce relaxed ordering when HW requires itdrivers/infiniband/core/umem.c | 2 +- drivers/infiniband/core/uverbs_std_types_mr.c | 4 +- drivers/infiniband/hw/mlx5/devx.c | 2 +- drivers/infiniband/hw/mlx5/main.c | 8 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 4 +- drivers/infiniband/hw/mlx5/mr.c | 79 ++++++++++--------- drivers/infiniband/hw/mlx5/odp.c | 1 + drivers/infiniband/hw/mlx5/umr.c | 18 ++--- drivers/infiniband/hw/mlx5/umr.h | 45 ++++++----- .../mellanox/mlx5/core/diag/rsc_dump.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 - .../ethernet/mellanox/mlx5/core/en/params.c | 2 +- .../ethernet/mellanox/mlx5/core/en_common.c | 13 +--Quoted 8 lines
.../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/mr.c | 21 +++++ drivers/vfio/pci/mlx5/cmd.c | 7 +- include/linux/mlx5/driver.h | 1 + include/linux/mlx5/mlx5_ifc.h | 24 ++++-- include/rdma/ib_verbs.h | 1 + include/uapi/rdma/ib_user_ioctl_verbs.h | 1 + 20 files changed, 134 insertions(+), 105 deletions(-)
Quoted 3 lines
Sashiko is not happy about this series.
Thanks
Sashiko has 4 comments on this series:
2 comments (on patch 14 and 15) concerning data-direct flows not handling the Unordered access flag or RO enforcement:
These are irrelevant as we don't have HW that will support both caps. That is currently an invalid configuration.
Comment on patch 3: suggesting we need a fix that is actually added in patch 4.
Comment on patch 15: Sashiko misreading the meaning of the cap.
'mkc_order_write_after_write_ro_only' means we must set RO in the write_after_write field of every mkey, regardless of actual write access flags at registration.
Thanks
Quoted 3 lines
Quoted 3 lines
--
2.52.0
Re: [PATCH rdma-next 06/15] net/mlx5: Add IFC bits for new ordering caps
In reply to Michael GurQuoted 8 lines · Michael Gur
Add new HCA capability bits:
-mkc_order_read_after_write
-mkc_order_write_after_write_ro_onlyAdd new mkey context field:
-order_read_after_write(2-bit)[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 10/15] RDMA/mlx5: Enable relaxed ordering on ODP null mkey
In reply to Michael GurQuoted 8 lines · Michael Gur
Enable relaxed ordering on the ODP implicit-MR null mkey. This allows supporting implicit ODP on HW that restricts memory registration with strict ordering.
No functional change as this is a null mkey with no memory mappings.
[...]
Signature · 1 line
Jason
Jason Gunthorpe
maintainerRe: [PATCH rdma-next 14/15] RDMA/mlx5: Support new Unordered access flag
In reply to Michael Gurdrivers/infiniband/hw/mlx5/mr.c static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr, · line 80
Quoted 12 lines
drivers/infiniband/hw/mlx5/mr.c +5
-1@@ -71,9 +71,14 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,MLX5_SET (mkc, mkc, lw, !!(acc &IB_ACCESS_LOCAL_WRITE ));MLX5_SET (mkc, mkc, lr,1 ); -if (acc &IB_ACCESS_RELAXED_ORDERING ) +if (acc & (IB_ACCESS_RELAXED_ORDERING |IB_ACCESS_UNORDERED ))mlx5_core_mkey_set_relaxed_ordering (dev->mdev, mkc); +if ((acc &IB_ACCESS_UNORDERED ) && +MLX5_CAP_GEN (dev->mdev, mkc_order_read_after_write)) +MLX5_SET (mkc, mkc, order_read_after_write, +MLX5_MKC_ORDER_READ_AFTER_WRITE_RO );
So we have this nice helper that sets all the bits then we open code other bits? Let's have the helper do everything?
Since the new bit is not umr able I would have expected this patch to also introduce some logic in the mkey key system so we are checking that the cached mkeys have the right mkc? (even though on this HW we expect them to all be uniform)
Signature · 1 line
Jason
Re: [PATCH rdma-next 13/15] RDMA/uverbs: Add new Unordered MR access flag
In reply to Michael GurQuoted 11 lines · Michael Gur
Add a new Unordered access flag for MR registrations.
This access flag allows additional relaxing of the order of memory accesses to the memory region.
Using this access flag allows for concurrent reads and writes of this MR to be reordered.This access flag is part of the optional access flags range, drivers shouldn't fail registration for any value in this range and are expected to treat them as best-effort.
[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 05/15] mlx5: Rename IFC bits of relaxed ordering fields
In reply to Michael GurQuoted 8 lines · Michael Gur
Align the IFC field names with the new naming:
-relaxed_ordering_write_umr->order_write_after_write_umr(cap)
-relaxed_ordering_read_umr->pci_relaxed_ordered_read_umr(cap)
-relaxed_ordering_write->mkc_order_write_after_write_ro(cap)
-relaxed_ordering_write->order_write_after_write(mkc)
-relaxed_ordering_read->pci_relaxed_ordered_read(cap and mkc)[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 12/15] RDMA/mlx5: Converge UMR access-flag cap checks
In reply to Michael GurQuoted 9 lines · Michael Gur
Move the UMR cap check from both MR registration and UMR paths to a single helper checking the access flags non-modifiable by UMR.
No behavior change for the current flag set.
Converge to prevent code duplication when adding support to new access flags that are not modifiable by UMR, like the new Unordered access flag added in following patches.[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 01/15] RDMA/mlx5: Allow optional access flags in DM registration
In reply to Michael GurQuoted 11 lines · Michael Gur
The uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.Add the optional access flag to the allow-lists of DM registrations. Uverbs users can now request any optional access flag on DM registrations and mlx5 will apply the flag's effect on a best-effort basis when supported.
[...]
Signature · 1 line
Jason
Jason Gunthorpe
maintainerRe: [PATCH rdma-next 11/15] RDMA/mlx5: Enable relaxed ordering on Memory Window mkey on strict-RO HW
In reply to Michael GurQuoted 7 lines
On hardware that restricts strong-ordering access for memory registrations, set relaxed ordering on MW mkeys. Without this change, MW allocation mkey creation fails on such HW.
Enabling RO implicitly for users in this case is acceptable since all users share the same memory registration restriction, so any MR bound to this MW is guaranteed to have relaxed ordering as well.
Are you sure this isn't a FW issue? With a KLM mkey what flags actually take effect? I would expect the leaf mkey to be the one that provides the actual in effect flags, not the MW.
If so then the FW shouldn't even be checking the ordering flags on the KLM creations?
It is harmless either way, but it doesn't seem right.
Signature · 1 line
Jason
Re: [PATCH rdma-next 03/15] RDMA/core: Allow optional access flags in dmabuf reg ioctl
In reply to Michael GurQuoted 11 lines · Michael Gur
The uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.Add the optional access flag to the allow-list of dmabuf registration ioctl. Uverbs users can now request any optional access flag on dmabuf registrations and drivers will apply the flag's effect on a best-effort basis when supported.
[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 04/15] RDMA/core: Allow optional access flags in reg mr ioctl
In reply to Michael GurQuoted 11 lines · Michael Gur
The uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.Add the optional access flag to the allow-list of dmabuf registration through the
reg_mrioctl. Uverbs users can now request any optional access flag on dmabuf registrations and mlx5 will apply the flag's effect on a best-effort basis when supported.[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 08/15] net/mlx5: Enable relaxed ordering on resource dump mkey
In reply to Michael GurQuoted 8 lines · Michael Gur
As resource dump logic reads data only following an event that is delivered with strong ordering, there is no need for strong ordering of its memory accesses.
Add relaxed ordering access flag to its registered memory, thus allowing better performance and allowing resource dump on HW that restricts strong ordering.[...]
Signature · 1 line
Jason
Jason Gunthorpe
maintainerQuoted 29 lines
This series prepares the mlx5 stack for hardware that restricts strong- ordered memory accesses, i.e. HW whose fabric doesn't guarantee memory operation ordering. The HW may choose to reject creation of an mkey that doesn't request relaxed ordering, so every mkey the driver creates - internal and user-facing - has to be handled accordingly.
The previously added 'ConnectX-10 NVLink-C2C' PCI device is such a device, as will be any future PCIe Gen7 UIO devices.
The series does four things:
1. Allow optional access flags on all memory registration
The uverbs ABI defines the optional access flags range as best-effort:
drivers must accept any flag in this range and treat support as opportunistic, never failing registration. Several registration paths (DM, DEVX UMEM, dmabuf ioctl,reg_mrioctl) did not allow this range and would reject such requests. These are fixed to allow newly added optional access flag added later in the series and any future optional access flag.2. Groundwork and internal mkeys
Rename the relaxed-ordering IFC fields to the new naming, add the new ordering capability and mkey-context bits, and consolidate RO-setting to a single helper inmlx5_coreso all consumers share one cap-gated implementation. Then enable relaxed ordering on the internal mkeys that don't require strong ordering (resource dump, vfio live-migration data, ODP null mkey, memory window mkey), so they keep working on strict-RO HW.
Quoted 6 lines
3. New Unordered access flag and enforcement
AddIB_ACCESS_UNORDERED, an optional access flag that additionally allows read-after-write reordering, and wire up mlx5 support for it.4. Enforce no-strong-ordering in user MR registration on HW that requires it.
You should mention the rdma-core series here which provides a full definition for what IB_ACCESS_UNORDERED actually means
Signature · 1 line
Jason
Re: [PATCH rdma-next 09/15] vfio/mlx5: Enable relaxed ordering on the live migration data mkey
In reply to Michael GurQuoted 9 lines · Michael Gur
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 themlx5_coreRO setter.This allows better performance and supporting vfio live migration on HW that restricts memory registration with strict ordering.
[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 02/15] RDMA/mlx5: Allow optional access flags in DEVX UMEM registration
In reply to Michael GurQuoted 11 lines · Michael Gur
The uverbs ABI reserves the optional access flags range as best-effort:
drivers should accept any flag in this range and treat the actual support as opportunistic, never failing registration when an optional flag is requested.Add the optional access flag to the allow-list of DEVX UMEM registration. Uverbs users can now request any optional access flag on these registrations and mlx5 will apply the flag's effect on a best-effort basis when supported.
[...]
Signature · 1 line
Jason
Re: [PATCH rdma-next 07/15] mlx5: Move RO setting helper to core and consolidate mlx5 consumers
In reply to Michael GurQuoted 14 lines
Move
mlx5e_mkey_set_relaxed_ordering()fromen_common.ctocore/mr.casmlx5_core_mkey_set_relaxed_ordering()and export it. The helper centralizes the cap gating fororder_write_after_writeandpci_relaxed_ordered_readso each consumer no longer has to open-code the same dance.Switch the static MR creation path (
set_mkc_access_pd_addr_fields) and the UMR access-modify path (mlx5r_umr_set_access_flags) over to the new helper. Both call it inside theIB_ACCESS_RELAXED_ORDERINGgate, preserving their existing conditional semantics: RO bits are only written when the caller actually requested RO. The Ethernet path already uses the helper unconditionally on every internal mkey it creates.
Quoted 5 lines
Consolidating onto the helper has two benefits beyond the deduplication itself:
*pcie_relaxed_ordering_enabled()is now invoked only when the caller requests RO, avoidingpci_lockcontention on every MR registration.
This is wrong anyhow, we shouldn't be checking PCI state in these methods, the same we don't check PCI ATS state or anything else.
If the FW supports the MKC bit it should accept it in the MKC and it is entirely fine if the FW decides to ignore it.
But at least as much as a code movement goes this looks OK
Signature · 1 line
Jason