From nobody Thu Apr 2 22:08:45 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B2213563EE; Fri, 13 Feb 2026 11:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770980464; cv=none; b=epMzOApNAAX/QFHypIsST+pRmAFktFZOE4fmm2MZvgwoTvOqc24rXiTQKYQHj/FZXksy8Wn+JqWyWqbTv3wSJCJhqnsLM0tHypvBVk2v01UTvAGh3+dRt04wfo7A2FRZKRLYWrMXXYXYpfFmuqMf8eTcBYOwP2oz6i7oA1EBke4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770980464; c=relaxed/simple; bh=cXVPMCACaL/gKFCQ/f3NUv6u2y9sogOUml+fOjhCVfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=el4pgY49LFuAf8+8tdv9Mc/NmjUTQBEH1zzZU4+zyN5WCI7P7dqIW8k8FndB5rAPwhXVjcKigYo2GGP1l+Tlpbuoc0GvHYojl+oN9PUWdbxh0MaWKYudORzFJlcDkGBrLfutWnuP9y9GjjlwIpBUdLE6Eaw7m+9KgVGoUWdCdJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=suCrbUt5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="suCrbUt5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 313DAC116C6; Fri, 13 Feb 2026 11:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770980464; bh=cXVPMCACaL/gKFCQ/f3NUv6u2y9sogOUml+fOjhCVfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=suCrbUt5uobz+J8Zy+H2OulDR2mfdrJR0brxW3fwatLE/yC+GHU1zAwiEII9nGIlH dwB7IM0le2zD/3l7+CsDSeQXhaZ30wsUn9AePU+13uEMQqCGmvv80yDQysD1LNPXMy BsN0wxScW7nm5ncAEhNBPrkkgWqKhYGXU/uoPkXPsOlrG2PTwIN1/qDK2+KAyBDuJe wUU8gBfSj9opmPAciR81jKqlqJ6jtSK4/YFNPU3q9CIXTNDJ/75rMJbFiZcG9IFDHd tTh4Wr8bl2lkx2F3s0iyqxv0ayEPgZqjz/nbflxUmcqzWsIgZBnNq/LZiV60TSLkBZ mP1U5Y6AXvWjw== From: Leon Romanovsky To: Jason Gunthorpe , Leon Romanovsky , Selvin Xavier , Kalesh AP , Potnuri Bharat Teja , Michael Margolin , Gal Pressman , Yossi Leybovich , Cheng Xu , Kai Shen , Chengchang Tang , Junxian Huang , Abhijit Gangurde , Allen Hubbe , Krzysztof Czurylo , Tatyana Nikolova , Long Li , Konstantin Taranov , Yishai Hadas , Michal Kalderon , Bryan Tan , Vishnu Dasa , Broadcom internal kernel review list , Christian Benvenuti , Nelson Escobar , Dennis Dalessandro , Bernard Metzler , Zhu Yanjun Cc: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: [PATCH rdma-next 35/50] RDMA/mlx4: Remove support for kernel CQ resize Date: Fri, 13 Feb 2026 12:58:11 +0200 Message-ID: <20260213-refactor-umem-v1-35-f3be85847922@nvidia.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260213-refactor-umem-v1-0-f3be85847922@nvidia.com> References: <20260213-refactor-umem-v1-0-f3be85847922@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-47773 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky No upper=E2=80=91layer protocol currently uses CQ resize, and the feature h= as no active callers. Drop the unused functionality. Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx4/cq.c | 167 +++++-------------------------------= ---- 1 file changed, 21 insertions(+), 146 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/c= q.c index 83169060d120..05fad06b89c2 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c @@ -296,30 +296,6 @@ int mlx4_ib_create_cq(struct ib_cq *ibcq, const struct= ib_cq_init_attr *attr, return err; } =20 -static int mlx4_alloc_resize_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_c= q *cq, - int entries) -{ - int err; - - if (cq->resize_buf) - return -EBUSY; - - cq->resize_buf =3D kmalloc(sizeof *cq->resize_buf, GFP_KERNEL); - if (!cq->resize_buf) - return -ENOMEM; - - err =3D mlx4_ib_alloc_cq_buf(dev, &cq->resize_buf->buf, entries); - if (err) { - kfree(cq->resize_buf); - cq->resize_buf =3D NULL; - return err; - } - - cq->resize_buf->cqe =3D entries - 1; - - return 0; -} - static int mlx4_alloc_resize_umem(struct mlx4_ib_dev *dev, struct mlx4_ib_= cq *cq, int entries, struct ib_udata *udata) { @@ -329,9 +305,6 @@ static int mlx4_alloc_resize_umem(struct mlx4_ib_dev *d= ev, struct mlx4_ib_cq *cq int n; int err; =20 - if (cq->resize_umem) - return -EBUSY; - if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) return -EFAULT; =20 @@ -371,91 +344,36 @@ static int mlx4_alloc_resize_umem(struct mlx4_ib_dev = *dev, struct mlx4_ib_cq *cq =20 err_umem: ib_umem_release(cq->resize_umem); - + cq->resize_umem =3D NULL; err_buf: kfree(cq->resize_buf); cq->resize_buf =3D NULL; return err; } =20 -static int mlx4_ib_get_outstanding_cqes(struct mlx4_ib_cq *cq) -{ - u32 i; - - i =3D cq->mcq.cons_index; - while (get_sw_cqe(cq, i)) - ++i; - - return i - cq->mcq.cons_index; -} - -static void mlx4_ib_cq_resize_copy_cqes(struct mlx4_ib_cq *cq) -{ - struct mlx4_cqe *cqe, *new_cqe; - int i; - int cqe_size =3D cq->buf.entry_size; - int cqe_inc =3D cqe_size =3D=3D 64 ? 1 : 0; - - i =3D cq->mcq.cons_index; - cqe =3D get_cqe(cq, i & cq->ibcq.cqe); - cqe +=3D cqe_inc; - - while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) !=3D MLX4_CQE_OPCODE= _RESIZE) { - new_cqe =3D get_cqe_from_buf(&cq->resize_buf->buf, - (i + 1) & cq->resize_buf->cqe); - memcpy(new_cqe, get_cqe(cq, i & cq->ibcq.cqe), cqe_size); - new_cqe +=3D cqe_inc; - - new_cqe->owner_sr_opcode =3D (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MAS= K) | - (((i + 1) & (cq->resize_buf->cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0); - cqe =3D get_cqe(cq, ++i & cq->ibcq.cqe); - cqe +=3D cqe_inc; - } - ++cq->mcq.cons_index; -} - int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *ud= ata) { struct mlx4_ib_dev *dev =3D to_mdev(ibcq->device); struct mlx4_ib_cq *cq =3D to_mcq(ibcq); struct mlx4_mtt mtt; - int outst_cqe; int err; =20 - mutex_lock(&cq->resize_mutex); - if (entries < 1 || entries > dev->dev->caps.max_cqes) { - err =3D -EINVAL; - goto out; - } + if (entries < 1 || entries > dev->dev->caps.max_cqes) + return -EINVAL; =20 entries =3D roundup_pow_of_two(entries + 1); - if (entries =3D=3D ibcq->cqe + 1) { - err =3D 0; - goto out; - } - - if (entries > dev->dev->caps.max_cqes + 1) { - err =3D -EINVAL; - goto out; - } + if (entries =3D=3D ibcq->cqe + 1) + return 0; =20 - if (ibcq->uobject) { - err =3D mlx4_alloc_resize_umem(dev, cq, entries, udata); - if (err) - goto out; - } else { - /* Can't be smaller than the number of outstanding CQEs */ - outst_cqe =3D mlx4_ib_get_outstanding_cqes(cq); - if (entries < outst_cqe + 1) { - err =3D -EINVAL; - goto out; - } + if (entries > dev->dev->caps.max_cqes + 1) + return -EINVAL; =20 - err =3D mlx4_alloc_resize_buf(dev, cq, entries); - if (err) - goto out; + mutex_lock(&cq->resize_mutex); + err =3D mlx4_alloc_resize_umem(dev, cq, entries, udata); + if (err) { + mutex_unlock(&cq->resize_mutex); + return err; } - mtt =3D cq->buf.mtt; =20 err =3D mlx4_cq_resize(dev->dev, &cq->mcq, entries, &cq->resize_buf->buf.= mtt); @@ -463,52 +381,26 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries= , struct ib_udata *udata) goto err_buf; =20 mlx4_mtt_cleanup(dev->dev, &mtt); - if (ibcq->uobject) { - cq->buf =3D cq->resize_buf->buf; - cq->ibcq.cqe =3D cq->resize_buf->cqe; - ib_umem_release(cq->ibcq.umem); - cq->ibcq.umem =3D cq->resize_umem; - - kfree(cq->resize_buf); - cq->resize_buf =3D NULL; - cq->resize_umem =3D NULL; - } else { - struct mlx4_ib_cq_buf tmp_buf; - int tmp_cqe =3D 0; - - spin_lock_irq(&cq->lock); - if (cq->resize_buf) { - mlx4_ib_cq_resize_copy_cqes(cq); - tmp_buf =3D cq->buf; - tmp_cqe =3D cq->ibcq.cqe; - cq->buf =3D cq->resize_buf->buf; - cq->ibcq.cqe =3D cq->resize_buf->cqe; - - kfree(cq->resize_buf); - cq->resize_buf =3D NULL; - } - spin_unlock_irq(&cq->lock); + cq->buf =3D cq->resize_buf->buf; + cq->ibcq.cqe =3D cq->resize_buf->cqe; + ib_umem_release(cq->ibcq.umem); + cq->ibcq.umem =3D cq->resize_umem; =20 - if (tmp_cqe) - mlx4_ib_free_cq_buf(dev, &tmp_buf, tmp_cqe); - } + kfree(cq->resize_buf); + cq->resize_buf =3D NULL; + cq->resize_umem =3D NULL; + mutex_unlock(&cq->resize_mutex); + return 0; =20 - goto out; =20 err_buf: mlx4_mtt_cleanup(dev->dev, &cq->resize_buf->buf.mtt); - if (!ibcq->uobject) - mlx4_ib_free_cq_buf(dev, &cq->resize_buf->buf, - cq->resize_buf->cqe); - kfree(cq->resize_buf); cq->resize_buf =3D NULL; =20 ib_umem_release(cq->resize_umem); cq->resize_umem =3D NULL; -out: mutex_unlock(&cq->resize_mutex); - return err; } =20 @@ -707,7 +599,6 @@ static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq, u16 wqe_ctr; unsigned tail =3D 0; =20 -repoll: cqe =3D next_cqe_sw(cq); if (!cqe) return -EAGAIN; @@ -727,22 +618,6 @@ static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq, is_error =3D (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) =3D=3D MLX4_CQE_OPCODE_ERROR; =20 - /* Resize CQ in progress */ - if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) =3D=3D MLX4_CQ= E_OPCODE_RESIZE)) { - if (cq->resize_buf) { - struct mlx4_ib_dev *dev =3D to_mdev(cq->ibcq.device); - - mlx4_ib_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe); - cq->buf =3D cq->resize_buf->buf; - cq->ibcq.cqe =3D cq->resize_buf->cqe; - - kfree(cq->resize_buf); - cq->resize_buf =3D NULL; - } - - goto repoll; - } - if (!*cur_qp || (be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK) !=3D (*cur_qp)->m= qp.qpn) { /* --=20 2.52.0