[PATCH rdma-next 45/50] RDMA/mlx4: Use generic resize-CQ lock

From: Leon Romanovsky

Date: Fri Feb 13 2026 - 06:13:18 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

Replace the open‑coded resize‑CQ lock with the standard core
implementation for better consistency and maintainability.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
drivers/infiniband/hw/mlx4/cq.c | 9 +--------
drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 -
2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index f4595afced45..ffc3902dc329 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -163,7 +163,6 @@ int mlx4_ib_create_user_cq(struct ib_cq *ibcq,

entries = roundup_pow_of_two(entries + 1);
cq->ibcq.cqe = entries - 1;
- mutex_init(&cq->resize_mutex);
spin_lock_init(&cq->lock);
INIT_LIST_HEAD(&cq->send_qp_list);
INIT_LIST_HEAD(&cq->recv_qp_list);
@@ -253,7 +252,6 @@ int mlx4_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,

entries = roundup_pow_of_two(entries + 1);
cq->ibcq.cqe = entries - 1;
- mutex_init(&cq->resize_mutex);
spin_lock_init(&cq->lock);
INIT_LIST_HEAD(&cq->send_qp_list);
INIT_LIST_HEAD(&cq->recv_qp_list);
@@ -369,12 +367,9 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
if (entries > dev->dev->caps.max_cqes + 1)
return -EINVAL;

- mutex_lock(&cq->resize_mutex);
err = mlx4_alloc_resize_umem(dev, cq, entries, udata);
- if (err) {
- mutex_unlock(&cq->resize_mutex);
+ if (err)
return err;
- }
mtt = cq->buf.mtt;

err = mlx4_cq_resize(dev->dev, &cq->mcq, entries, &cq->resize_buf->buf.mtt);
@@ -390,7 +385,6 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
kfree(cq->resize_buf);
cq->resize_buf = NULL;
cq->resize_umem = NULL;
- mutex_unlock(&cq->resize_mutex);
return 0;


@@ -401,7 +395,6 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,

ib_umem_release(cq->resize_umem);
cq->resize_umem = NULL;
- mutex_unlock(&cq->resize_mutex);
return err;
}

diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 5a799d6df93e..2f1043690554 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -120,7 +120,6 @@ struct mlx4_ib_cq {
struct mlx4_ib_cq_resize *resize_buf;
struct mlx4_db db;
spinlock_t lock;
- struct mutex resize_mutex;
struct ib_umem *resize_umem;
/* List of qps that it serves.*/
struct list_head send_qp_list;

--
2.52.0