mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Srouji <edwards@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	"Sabrina Dubroca" <sd@queasysnail.net>
Cc: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, Edward Srouji <edwards@nvidia.com>,
	"Akiva Goldberger" <agoldberger@nvidia.com>,
	Michael Gur <michaelgur@nvidia.com>
Subject: [PATCH rdma-next 09/11] RDMA/mlx5: Cache the CQ core device and resolve it via cq_to_mdev()
Date: Tue, 17 Nov 2026 16:01:20 +0200	[thread overview]
Message-ID: <20261117-mlx5-sd-prep-v1-9-8efd124c7895@nvidia.com> (raw)
In-Reply-To: <20261117-mlx5-sd-prep-v1-0-8efd124c7895@nvidia.com>

From: Akiva Goldberger <agoldberger@nvidia.com>

A CQ can be created by the user or the kernel, so it doesn't always have
a user context, and it has no attached PD. Therefore, it lacks a
reliable source for resolving the core device it was created on.  Cache
the core device in mlx5_ib_cq at create time and add the cq_to_mdev()
helper to resolve the core device instead of using the dev->mdev
reference.

No functional change.

Signed-off-by: Akiva Goldberger <agoldberger@nvidia.com>
Reviewed-by: Michael Gur <michaelgur@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
 drivers/infiniband/hw/mlx5/cq.c       | 102 ++++++++++++++++++----------------
 drivers/infiniband/hw/mlx5/mlx5_ib.h  |   6 ++
 drivers/infiniband/hw/mlx5/qp.c       |   2 +-
 drivers/infiniband/hw/mlx5/restrack.c |  14 ++---
 4 files changed, 66 insertions(+), 58 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
index b28ce05fab8f3d668d4e9b43c5562e7a88c37b4a..5eaf50fe7f540c3fb1c909f19589ece932bcb2b4 100644
--- a/drivers/infiniband/hw/mlx5/cq.c
+++ b/drivers/infiniband/hw/mlx5/cq.c
@@ -358,9 +358,9 @@ static void handle_atomics(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64,
 	qp->sq.last_poll = tail;
 }
 
-static void free_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf)
+static void free_cq_buf(struct mlx5_core_dev *mdev, struct mlx5_ib_cq_buf *buf)
 {
-	mlx5_frag_buf_free(dev->mdev, &buf->frag_buf);
+	mlx5_frag_buf_free(mdev, &buf->frag_buf);
 }
 
 static void get_sig_err_item(struct mlx5_sig_err_cqe *cqe,
@@ -480,7 +480,7 @@ static int mlx5_poll_one(struct mlx5_ib_cq *cq,
 	opcode = get_cqe_opcode(cqe64);
 	if (unlikely(opcode == MLX5_CQE_RESIZE_CQ)) {
 		if (likely(cq->resize_buf)) {
-			free_cq_buf(dev, &cq->buf);
+			free_cq_buf(cq_to_mdev(cq), &cq->buf);
 			cq->buf = *cq->resize_buf;
 			kfree(cq->resize_buf);
 			cq->resize_buf = NULL;
@@ -612,8 +612,7 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
 {
 	struct mlx5_ib_cq *cq = to_mcq(ibcq);
 	struct mlx5_ib_qp *cur_qp = NULL;
-	struct mlx5_ib_dev *dev = to_dev(cq->ibcq.device);
-	struct mlx5_core_dev *mdev = dev->mdev;
+	struct mlx5_core_dev *mdev = cq_to_mdev(cq);
 	unsigned long flags;
 	int soft_polled = 0;
 	int npolled;
@@ -647,8 +646,8 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
 
 int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
 {
-	struct mlx5_core_dev *mdev = to_dev(ibcq->device)->mdev;
 	struct mlx5_ib_cq *cq = to_mcq(ibcq);
+	struct mlx5_core_dev *mdev = cq_to_mdev(cq);
 	void __iomem *uar_page = mdev->priv.bfreg.up->map;
 	unsigned long irq_flags;
 	int ret = 0;
@@ -669,7 +668,7 @@ int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
 	return ret;
 }
 
-static int alloc_cq_frag_buf(struct mlx5_ib_dev *dev,
+static int alloc_cq_frag_buf(struct mlx5_core_dev *mdev,
 			     struct mlx5_ib_cq_buf *buf,
 			     int nent,
 			     int cqe_size)
@@ -679,10 +678,10 @@ static int alloc_cq_frag_buf(struct mlx5_ib_dev *dev,
 	u8 log_wq_sz     = ilog2(cqe_size);
 	int err;
 
-	err = mlx5_frag_buf_alloc_node(dev->mdev,
+	err = mlx5_frag_buf_alloc_node(mdev,
 				       nent * cqe_size,
 				       frag_buf,
-				       dev->mdev->priv.numa_node);
+				       mdev->priv.numa_node);
 	if (err)
 		return err;
 
@@ -700,7 +699,7 @@ enum {
 	MLX5_CQE_RES_FORMAT_CSUM_STRIDX = 3,
 };
 
-static int mini_cqe_res_format_to_hw(struct mlx5_ib_dev *dev, u8 format)
+static int mini_cqe_res_format_to_hw(struct mlx5_core_dev *mdev, u8 format)
 {
 	switch (format) {
 	case MLX5_IB_CQE_RES_FORMAT_HASH:
@@ -708,7 +707,7 @@ static int mini_cqe_res_format_to_hw(struct mlx5_ib_dev *dev, u8 format)
 	case MLX5_IB_CQE_RES_FORMAT_CSUM:
 		return MLX5_CQE_RES_FORMAT_CSUM;
 	case MLX5_IB_CQE_RES_FORMAT_CSUM_STRIDX:
-		if (MLX5_CAP_GEN(dev->mdev, mini_cqe_resp_stride_index))
+		if (MLX5_CAP_GEN(mdev, mini_cqe_resp_stride_index))
 			return MLX5_CQE_RES_FORMAT_CSUM_STRIDX;
 		return -EOPNOTSUPP;
 	default:
@@ -807,9 +806,9 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
 		int mini_cqe_format;
 
 		if (!((*cqe_size == 128 &&
-		       MLX5_CAP_GEN(dev->mdev, cqe_compression_128)) ||
+		       MLX5_CAP_GEN(cq_to_mdev(cq), cqe_compression_128)) ||
 		      (*cqe_size == 64  &&
-		       MLX5_CAP_GEN(dev->mdev, cqe_compression)))) {
+		       MLX5_CAP_GEN(cq_to_mdev(cq), cqe_compression)))) {
 			err = -EOPNOTSUPP;
 			mlx5_ib_warn(dev, "CQE compression is not supported for size %d!\n",
 				     *cqe_size);
@@ -817,7 +816,7 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
 		}
 
 		mini_cqe_format =
-			mini_cqe_res_format_to_hw(dev,
+			mini_cqe_res_format_to_hw(cq_to_mdev(cq),
 						  ucmd.cqe_comp_res_format);
 		if (mini_cqe_format < 0) {
 			err = mini_cqe_format;
@@ -832,7 +831,7 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
 
 	if (ucmd.flags & MLX5_IB_CREATE_CQ_FLAGS_CQE_128B_PAD) {
 		if (*cqe_size != 128 ||
-		    !MLX5_CAP_GEN(dev->mdev, cqe_128_always)) {
+		    !MLX5_CAP_GEN(cq_to_mdev(cq), cqe_128_always)) {
 			err = -EOPNOTSUPP;
 			mlx5_ib_warn(dev,
 				     "CQE padding is not supported for CQE size of %dB!\n",
@@ -882,7 +881,7 @@ static void init_cq_frag_buf(struct mlx5_ib_cq_buf *buf)
 	}
 }
 
-static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
+static int create_cq_kernel(struct mlx5_ib_cq *cq,
 			    int entries, int cqe_size,
 			    u32 **cqb, int *index, int *inlen)
 {
@@ -890,7 +889,7 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
 	void *cqc;
 	int err;
 
-	err = mlx5_db_alloc(dev->mdev, &cq->db);
+	err = mlx5_db_alloc(cq_to_mdev(cq), &cq->db);
 	if (err)
 		return err;
 
@@ -898,7 +897,7 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
 	cq->mcq.arm_db     = cq->db.db + 1;
 	cq->mcq.cqe_sz = cqe_size;
 
-	err = alloc_cq_frag_buf(dev, &cq->buf, entries, cqe_size);
+	err = alloc_cq_frag_buf(cq_to_mdev(cq), &cq->buf, entries, cqe_size);
 	if (err)
 		goto err_db;
 
@@ -921,22 +920,22 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
 		 cq->buf.frag_buf.page_shift -
 		 MLX5_ADAPTER_PAGE_SHIFT);
 
-	*index = dev->mdev->priv.bfreg.up->index;
+	*index = cq_to_mdev(cq)->priv.bfreg.up->index;
 
 	return 0;
 
 err_buf:
-	free_cq_buf(dev, &cq->buf);
+	free_cq_buf(cq_to_mdev(cq), &cq->buf);
 
 err_db:
-	mlx5_db_free(dev->mdev, &cq->db);
+	mlx5_db_free(cq_to_mdev(cq), &cq->db);
 	return err;
 }
 
-static void destroy_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq)
+static void destroy_cq_kernel(struct mlx5_ib_cq *cq)
 {
-	free_cq_buf(dev, &cq->buf);
-	mlx5_db_free(dev->mdev, &cq->db);
+	free_cq_buf(cq_to_mdev(cq), &cq->buf);
+	mlx5_db_free(cq_to_mdev(cq), &cq->db);
 }
 
 static void notify_soft_wc_handler(struct work_struct *work)
@@ -967,14 +966,16 @@ int mlx5_ib_create_user_cq(struct ib_cq *ibcq,
 	int eqn;
 	int err;
 
-	if (attr->cqe > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))
+	cq->mdev = dev->mdev;
+
+	if (attr->cqe > (1 << MLX5_CAP_GEN(cq_to_mdev(cq), log_max_cq_sz)))
 		return -EINVAL;
 
 	if (check_cq_create_flags(attr->flags))
 		return -EOPNOTSUPP;
 
 	entries = roundup_pow_of_two(entries + 1);
-	if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))
+	if (entries > (1 << MLX5_CAP_GEN(cq_to_mdev(cq), log_max_cq_sz)))
 		return -EINVAL;
 
 	cq->ibcq.cqe = entries - 1;
@@ -990,7 +991,7 @@ int mlx5_ib_create_user_cq(struct ib_cq *ibcq,
 	if (err)
 		return err;
 
-	err = mlx5_comp_eqn_get(dev->mdev, vector, &eqn);
+	err = mlx5_comp_eqn_get(cq_to_mdev(cq), vector, &eqn);
 	if (err)
 		goto err_cqb;
 
@@ -1011,7 +1012,8 @@ int mlx5_ib_create_user_cq(struct ib_cq *ibcq,
 	cq->mcq.comp = mlx5_add_cq_to_tasklet;
 	cq->mcq.tasklet_ctx.comp = mlx5_ib_cq_comp;
 
-	err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen, out, sizeof(out));
+	err = mlx5_core_create_cq(cq_to_mdev(cq), &cq->mcq, cqb, inlen, out,
+				  sizeof(out));
 	if (err)
 		goto err_cqb;
 
@@ -1029,7 +1031,7 @@ int mlx5_ib_create_user_cq(struct ib_cq *ibcq,
 	return 0;
 
 err_cmd:
-	mlx5_core_destroy_cq(dev->mdev, &cq->mcq);
+	mlx5_core_destroy_cq(cq_to_mdev(cq), &cq->mcq);
 
 err_cqb:
 	kvfree(cqb);
@@ -1055,11 +1057,13 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 	int eqn;
 	int err;
 
-	if (attr->cqe > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))
+	cq->mdev = dev->mdev;
+
+	if (attr->cqe > (1 << MLX5_CAP_GEN(cq_to_mdev(cq), log_max_cq_sz)))
 		return -EINVAL;
 
 	entries = roundup_pow_of_two(entries + 1);
-	if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))
+	if (entries > (1 << MLX5_CAP_GEN(cq_to_mdev(cq), log_max_cq_sz)))
 		return -EINVAL;
 
 	cq->ibcq.cqe = entries - 1;
@@ -1069,14 +1073,14 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 	INIT_LIST_HEAD(&cq->list_recv_qp);
 
 	cqe_size = cache_line_size() == 128 ? 128 : 64;
-	err = create_cq_kernel(dev, cq, entries, cqe_size, &cqb, &index,
+	err = create_cq_kernel(cq, entries, cqe_size, &cqb, &index,
 			       &inlen);
 	if (err)
 		return err;
 
 	INIT_WORK(&cq->notify_work, notify_soft_wc_handler);
 
-	err = mlx5_comp_eqn_get(dev->mdev, vector, &eqn);
+	err = mlx5_comp_eqn_get(cq_to_mdev(cq), vector, &eqn);
 	if (err)
 		goto err_cqb;
 
@@ -1094,7 +1098,7 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 
 	cq->mcq.comp = mlx5_ib_cq_comp;
 
-	err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen, out,
+	err = mlx5_core_create_cq(cq_to_mdev(cq), &cq->mcq, cqb, inlen, out,
 				  sizeof(out));
 	if (err)
 		goto err_cqb;
@@ -1108,25 +1112,24 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 
 err_cqb:
 	kvfree(cqb);
-	destroy_cq_kernel(dev, cq);
+	destroy_cq_kernel(cq);
 	return err;
 }
 
 int mlx5_ib_pre_destroy_cq(struct ib_cq *cq)
 {
-	struct mlx5_ib_dev *dev = to_dev(cq->device);
 	struct mlx5_ib_cq *mcq = to_mcq(cq);
 
 	if (!cq->uobject)
 		cancel_work_sync(&mcq->notify_work);
 
-	return mlx5_core_destroy_cq(dev->mdev, &mcq->mcq);
+	return mlx5_core_destroy_cq(cq_to_mdev(mcq), &mcq->mcq);
 }
 
 void mlx5_ib_post_destroy_cq(struct ib_cq *cq)
 {
 	WARN_ON(!list_empty(&to_mcq(cq)->wc_list));
-	destroy_cq_kernel(to_dev(cq->device), to_mcq(cq));
+	destroy_cq_kernel(to_mcq(cq));
 }
 
 int mlx5_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
@@ -1217,13 +1220,13 @@ int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
 	struct mlx5_ib_cq *mcq = to_mcq(cq);
 	int err;
 
-	if (!MLX5_CAP_GEN(dev->mdev, cq_moderation))
+	if (!MLX5_CAP_GEN(cq_to_mdev(mcq), cq_moderation))
 		return -EOPNOTSUPP;
 
 	if (cq_period > MLX5_MAX_CQ_PERIOD)
 		return -EINVAL;
 
-	err = mlx5_core_modify_cq_moderation(dev->mdev, &mcq->mcq,
+	err = mlx5_core_modify_cq_moderation(cq_to_mdev(mcq), &mcq->mcq,
 					     cq_period, cq_count);
 	if (err)
 		mlx5_ib_warn(dev, "modify cq 0x%x failed\n", mcq->mcq.cqn);
@@ -1264,7 +1267,7 @@ static int resize_user(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
 	return 0;
 }
 
-static int resize_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
+static int resize_kernel(struct mlx5_ib_cq *cq,
 			 int entries, int cqe_size)
 {
 	int err;
@@ -1273,7 +1276,8 @@ static int resize_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
 	if (!cq->resize_buf)
 		return -ENOMEM;
 
-	err = alloc_cq_frag_buf(dev, cq->resize_buf, entries, cqe_size);
+	err = alloc_cq_frag_buf(cq_to_mdev(cq), cq->resize_buf, entries,
+				cqe_size);
 	if (err)
 		goto ex;
 
@@ -1357,16 +1361,16 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
 	int cqe_size;
 	unsigned long flags;
 
-	if (!MLX5_CAP_GEN(dev->mdev, cq_resize)) {
+	if (!MLX5_CAP_GEN(cq_to_mdev(cq), cq_resize)) {
 		pr_info("Firmware does not support resize CQ\n");
 		return -ENOSYS;
 	}
 
-	if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))
+	if (entries > (1 << MLX5_CAP_GEN(cq_to_mdev(cq), log_max_cq_sz)))
 		return -EINVAL;
 
 	entries = roundup_pow_of_two(entries + 1);
-	if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1)
+	if (entries > (1 << MLX5_CAP_GEN(cq_to_mdev(cq), log_max_cq_sz)) + 1)
 		return -EINVAL;
 
 	if (entries == ibcq->cqe + 1)
@@ -1394,7 +1398,7 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
 		struct mlx5_frag_buf *frag_buf;
 
 		cqe_size = 64;
-		err = resize_kernel(dev, cq, entries, cqe_size);
+		err = resize_kernel(cq, entries, cqe_size);
 		if (err)
 			goto ex;
 		frag_buf = &cq->resize_buf->frag_buf;
@@ -1438,7 +1442,7 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
 	MLX5_SET(modify_cq_in, in, op_mod, MLX5_CQ_OPMOD_RESIZE);
 	MLX5_SET(modify_cq_in, in, cqn, cq->mcq.cqn);
 
-	err = mlx5_core_modify_cq(dev->mdev, &cq->mcq, in, inlen);
+	err = mlx5_core_modify_cq(cq_to_mdev(cq), &cq->mcq, in, inlen);
 	if (err)
 		goto ex_alloc;
 
@@ -1465,7 +1469,7 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
 		cq->ibcq.cqe = entries - 1;
 		spin_unlock_irqrestore(&cq->lock, flags);
 		if (resized)
-			free_cq_buf(dev, &tbuf);
+			free_cq_buf(cq_to_mdev(cq), &tbuf);
 	}
 	mutex_unlock(&cq->resize_mutex);
 
@@ -1478,7 +1482,7 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
 ex_resize:
 	ib_umem_release(cq->resize_umem);
 	if (!udata) {
-		free_cq_buf(dev, cq->resize_buf);
+		free_cq_buf(cq_to_mdev(cq), cq->resize_buf);
 		cq->resize_buf = NULL;
 	}
 ex:
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 15d28cad7ea6c1778419e490ccc9c78c24920a06..61c663c7bfc9cf20b3b40dbb8aa4f621fe1d8ea8 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -572,6 +572,7 @@ enum mlx5_ib_cq_pr_flags {
 struct mlx5_ib_cq {
 	struct ib_cq		ibcq;
 	struct mlx5_core_cq	mcq;
+	struct mlx5_core_dev	*mdev;
 	struct mlx5_ib_cq_buf	buf;
 	struct mlx5_db		db;
 
@@ -1305,6 +1306,11 @@ static inline struct mlx5_core_dev *uctx_to_mdev(struct mlx5_ib_ucontext *uctx)
 	return to_dev(uctx->ibucontext.device)->mdev;
 }
 
+static inline struct mlx5_core_dev *cq_to_mdev(struct mlx5_ib_cq *cq)
+{
+	return cq->mdev;
+}
+
 static inline struct mlx5_ib_mw *to_mmw(struct ib_mw *ibmw)
 {
 	return container_of(ibmw, struct mlx5_ib_mw, ibmw);
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 1135e710e339818aaa15f1077874561745ca6305..01babb9a0003abe2520200fcec2e9eb9224516e7 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -5878,7 +5878,7 @@ static void handle_drain_completion(struct ib_cq *cq,
 				    struct mlx5_ib_drain_cqe *sdrain,
 				    struct mlx5_ib_dev *dev)
 {
-	struct mlx5_core_dev *mdev = dev->mdev;
+	struct mlx5_core_dev *mdev = cq_to_mdev(to_mcq(cq));
 
 	if (cq->poll_ctx == IB_POLL_DIRECT) {
 		while (wait_for_completion_timeout(&sdrain->done, HZ / 10) <= 0)
diff --git a/drivers/infiniband/hw/mlx5/restrack.c b/drivers/infiniband/hw/mlx5/restrack.c
index 866252cdce52452968519c8e785068a27cd40a34..f38fe7f694bae29bf23b15dddc46aa541545f761 100644
--- a/drivers/infiniband/hw/mlx5/restrack.c
+++ b/drivers/infiniband/hw/mlx5/restrack.c
@@ -56,7 +56,7 @@ static int dump_rsc(struct mlx5_core_dev *mdev, enum mlx5_sgmt_type type,
 	return err;
 }
 
-static int fill_res_raw(struct sk_buff *msg, struct mlx5_ib_dev *dev,
+static int fill_res_raw(struct sk_buff *msg, struct mlx5_core_dev *mdev,
 			enum mlx5_sgmt_type type, u32 key)
 {
 	int len = 0;
@@ -67,7 +67,7 @@ static int fill_res_raw(struct sk_buff *msg, struct mlx5_ib_dev *dev,
 	if (!data)
 		return -ENOMEM;
 
-	err = dump_rsc(dev->mdev, type, key, data, &len);
+	err = dump_rsc(mdev, type, key, data, &len);
 	if (err)
 		goto out;
 
@@ -124,7 +124,7 @@ static int fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ibmr)
 {
 	struct mlx5_ib_mr *mr = to_mmr(ibmr);
 
-	return fill_res_raw(msg, mr_to_dev(mr), MLX5_SGMT_TYPE_PRM_QUERY_MKEY,
+	return fill_res_raw(msg, mr_to_mdev(mr), MLX5_SGMT_TYPE_PRM_QUERY_MKEY,
 			    mlx5_mkey_to_idx(mr->mmkey.key));
 }
 
@@ -158,10 +158,10 @@ static int fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr)
 
 static int fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq)
 {
-	struct mlx5_ib_dev *dev = to_dev(ibcq->device);
 	struct mlx5_ib_cq *cq = to_mcq(ibcq);
 
-	return fill_res_raw(msg, dev, MLX5_SGMT_TYPE_PRM_QUERY_CQ, cq->mcq.cqn);
+	return fill_res_raw(msg, cq_to_mdev(cq), MLX5_SGMT_TYPE_PRM_QUERY_CQ,
+			    cq->mcq.cqn);
 }
 
 static int fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp)
@@ -191,9 +191,7 @@ static int fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp)
 
 static int fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ibqp)
 {
-	struct mlx5_ib_dev *dev = to_dev(ibqp->device);
-
-	return fill_res_raw(msg, dev, MLX5_SGMT_TYPE_PRM_QUERY_QP,
+	return fill_res_raw(msg, qp_to_mdev(ibqp), MLX5_SGMT_TYPE_PRM_QUERY_QP,
 			    ibqp->qp_num);
 }
 

-- 
2.49.0


  parent reply	other threads:[~2026-11-17 14:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:01 [PATCH rdma-next 00/11] RDMA/mlx5: Preparation for SD support Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 01/11] RDMA/mlx5: Enforce dev/mdev naming for device pointers Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 02/11] RDMA/mlx5: Rename to_mdev() helpers that return an IB device Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 03/11] RDMA/mlx5: Select the PD and SRQ core device through the PD Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 04/11] RDMA/mlx5: Select the core device through PD for QP commands Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 05/11] RDMA/mlx5: Cache the MR core device and resolve the MW's via its PD Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 06/11] RDMA/mlx5: Select the AH core device through their PD Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 07/11] RDMA/mlx5: Select the QP core device through its PD Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 08/11] RDMA/mlx5: Resolve core device from ucontext for DEVX resources Edward Srouji
2026-11-17 14:01 ` Edward Srouji [this message]
2026-11-17 14:01 ` [PATCH rdma-next 10/11] RDMA/mlx5: Resolve the bfreg UAR-index core device from the ucontext Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 11/11] RDMA/mlx5: Resolve UAR and mmap core devices via " Edward Srouji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117-mlx5-sd-prep-v1-9-8efd124c7895@nvidia.com \
    --to=edwards@nvidia.com \
    --cc=agoldberger@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michaelgur@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®