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

From: Leon Romanovsky

Date: Fri Feb 13 2026 - 06:12:13 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/mthca/mthca_cq.c | 1 -
drivers/infiniband/hw/mthca/mthca_provider.c | 20 ++++++--------------
drivers/infiniband/hw/mthca/mthca_provider.h | 1 -
3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 26c3408dcaca..9c15e9b886d1 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -819,7 +819,6 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
spin_lock_init(&cq->lock);
cq->refcount = 1;
init_waitqueue_head(&cq->wait);
- mutex_init(&cq->mutex);

memset(cq_context, 0, sizeof *cq_context);
cq_context->flags = cpu_to_be32(MTHCA_CQ_STATUS_OK |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 85de004547ab..cb94d73e89d6 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -680,28 +680,20 @@ static int mthca_resize_cq(struct ib_cq *ibcq, unsigned int entries,
if (entries > dev->limits.max_cqes)
return -EINVAL;

- mutex_lock(&cq->mutex);
-
entries = roundup_pow_of_two(entries + 1);
- if (entries == ibcq->cqe + 1) {
- ret = 0;
- goto out;
- }
+ if (entries == ibcq->cqe + 1)
+ return 0;

- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
- ret = -EFAULT;
- goto out;
- }
+ if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)))
+ return -EFAULT;
lkey = ucmd.lkey;

ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries));
if (ret)
- goto out;
+ return ret;

ibcq->cqe = entries - 1;
-out:
- mutex_unlock(&cq->mutex);
- return ret;
+ return 0;
}

static int mthca_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 8a77483bb33c..7797d76fb93d 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -198,7 +198,6 @@ struct mthca_cq {
int arm_sn;

wait_queue_head_t wait;
- struct mutex mutex;
};

struct mthca_srq {

--
2.52.0