drivers/infiniband/hw/mlx5/umr.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/umr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/umr.c- Extension
.c- Size
- 31476 bytes
- Lines
- 1121
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
rdma/ib_umem_odp.hrdma/iter.hmlx5_ib.humr.hwr.h
Detected Declarations
function get_umr_enable_mr_maskfunction get_umr_disable_mr_maskfunction get_umr_update_translation_maskfunction get_umr_update_access_maskfunction get_umr_update_pd_maskfunction umr_check_mkey_maskfunction mlx5r_umr_qp_rst2rtsfunction mlx5r_umr_resource_initfunction mlx5r_umr_resource_cleanupfunction mlx5r_umr_initfunction mlx5r_umr_cleanupfunction mlx5r_umr_post_sendfunction mlx5r_umr_recoverfunction mlx5r_umr_donefunction mlx5r_umr_init_contextfunction mlx5r_umr_post_send_waitfunction mlx5r_umr_revoke_mrfunction mlx5r_umr_set_access_flagsfunction mlx5r_umr_rereg_pd_accessfunction mlx5r_umr_free_xltfunction mlx5r_umr_unmap_free_xltfunction mlx5r_umr_set_update_xlt_ctrl_segfunction mlx5r_umr_set_update_xlt_mkey_segfunction mlx5r_umr_set_update_xlt_data_segfunction mlx5r_umr_update_offsetfunction mlx5r_umr_final_update_xltfunction _mlx5r_umr_init_wqefunction _mlx5r_umr_update_mr_pasfunction rdma_umem_for_each_dma_blockfunction mlx5r_umr_update_data_direct_ksm_pas_rangefunction mlx5r_umr_update_data_direct_ksm_pasfunction mlx5r_umr_update_mr_pas_rangefunction mlx5r_umr_update_mr_pasfunction umr_can_use_indirect_mkeyfunction mlx5r_umr_update_xltfunction changedfunction _mlx5r_dmabuf_umr_update_pasfunction zappingfunction mlx5r_umr_dmabuf_update_pgsz
Annotated Snippet
if (umrc->state == MLX5_UMR_STATE_ERR) {
mutex_unlock(&umrc->lock);
err = -EFAULT;
break;
}
if (umrc->state == MLX5_UMR_STATE_RECOVER) {
mutex_unlock(&umrc->lock);
usleep_range(3000, 5000);
continue;
}
err = mlx5r_umr_post_send(umrc->qp, mkey, &umr_context.cqe, wqe,
with_data);
mutex_unlock(&umrc->lock);
if (err) {
mlx5_ib_warn(dev, "UMR post send failed, err %d\n",
err);
break;
}
wait_for_completion(&umr_context.done);
if (umr_context.status == IB_WC_SUCCESS)
break;
if (umr_context.status == IB_WC_WR_FLUSH_ERR)
continue;
WARN_ON_ONCE(1);
mlx5_ib_warn(dev,
"reg umr failed (%u). Trying to recover and resubmit the flushed WQEs, mkey = %u\n",
umr_context.status, mkey);
err = mlx5r_umr_recover(dev, mkey, &umr_context, wqe, with_data);
if (err)
mlx5_ib_warn(dev, "couldn't recover UMR, err %d\n",
err);
err = -EFAULT;
break;
}
up(&umrc->sem);
return err;
}
/**
* mlx5r_umr_revoke_mr - Fence all DMA on the MR
* @mr: The MR to fence
*
* Upon return the NIC will not be doing any DMA to the pages under the MR,
* and any DMA in progress will be completed. Failure of this function
* indicates the HW has failed catastrophically.
*/
int mlx5r_umr_revoke_mr(struct mlx5_ib_mr *mr)
{
struct mlx5_ib_dev *dev = mr_to_mdev(mr);
struct mlx5r_umr_wqe wqe = {};
if (dev->mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
return 0;
wqe.ctrl_seg.mkey_mask |= get_umr_update_pd_mask();
wqe.ctrl_seg.mkey_mask |= get_umr_disable_mr_mask();
wqe.ctrl_seg.flags |= MLX5_UMR_INLINE;
MLX5_SET(mkc, &wqe.mkey_seg, free, 1);
MLX5_SET(mkc, &wqe.mkey_seg, pd, to_mpd(dev->umrc.pd)->pdn);
MLX5_SET(mkc, &wqe.mkey_seg, qpn, 0xffffff);
MLX5_SET(mkc, &wqe.mkey_seg, mkey_7_0,
mlx5_mkey_variant(mr->mmkey.key));
return mlx5r_umr_post_send_wait(dev, mr->mmkey.key, &wqe, false);
}
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, relaxed_ordering_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, relaxed_ordering_write,
!!(access_flags & IB_ACCESS_RELAXED_ORDERING));
MLX5_SET(mkc, seg, relaxed_ordering_read, ro_read);
}
Annotation
- Immediate include surface: `rdma/ib_umem_odp.h`, `rdma/iter.h`, `mlx5_ib.h`, `umr.h`, `wr.h`.
- Detected declarations: `function get_umr_enable_mr_mask`, `function get_umr_disable_mr_mask`, `function get_umr_update_translation_mask`, `function get_umr_update_access_mask`, `function get_umr_update_pd_mask`, `function umr_check_mkey_mask`, `function mlx5r_umr_qp_rst2rts`, `function mlx5r_umr_resource_init`, `function mlx5r_umr_resource_cleanup`, `function mlx5r_umr_init`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.