The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=fbe76ea44c4b35ff1226b19c8e3913716686e4f4
commit fbe76ea44c4b35ff1226b19c8e3913716686e4f4 Author: John Baldwin <[email protected]> AuthorDate: 2026-05-28 15:52:03 +0000 Commit: John Baldwin <[email protected]> CommitDate: 2026-06-22 18:36:52 +0000 OFED: Use vmalloc() and vzalloc() in various places This contains changes from the following Linux commits: 10313cbb9220 IPoIB: Allocate priv->tx_ring with vmalloc() b1404069f644 IPoIB/cm: Use vmalloc() to allocate rx_rings 948579cd8c6e RDMA: Use vzalloc() to replace vmalloc()+memset(0) Tested by: Wafa Hamzah <[email protected]> (mlx5_ib) Tested by: John Baldwin <[email protected]> (iw_cxgbe) Sponsored by: Chelsio Communications --- sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c | 17 +++++++---------- sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c | 7 +++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 03487afedd55..61db58d2b6c7 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c @@ -44,6 +44,7 @@ #include <rdma/ib_cm.h> #include <rdma/ib_cache.h> #include <linux/delay.h> +#include <linux/vmalloc.h> int ipoib_max_conn_qp = 128; @@ -165,7 +166,7 @@ static void ipoib_cm_free_rx_ring(struct ipoib_dev_priv *priv, m_freem(rx_ring[i].mb); } - kfree(rx_ring); + vfree(rx_ring); } static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv) @@ -307,15 +308,13 @@ static int ipoib_cm_nonsrq_init_rx(struct ipoib_dev_priv *priv, int ret; int i; - rx->rx_ring = kzalloc(ipoib_recvq_size * sizeof *rx->rx_ring, GFP_KERNEL); + rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring); if (!rx->rx_ring) { printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n", priv->ca->name, ipoib_recvq_size); return -ENOMEM; } - memset(rx->rx_ring, 0, ipoib_recvq_size * sizeof *rx->rx_ring); - t = kmalloc(sizeof *t, GFP_KERNEL); if (!t) { ret = -ENOMEM; @@ -1007,13 +1006,12 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, struct ipoib_dev_priv *priv = p->priv; int ret; - p->tx_ring = kzalloc(ipoib_sendq_size * sizeof *p->tx_ring, GFP_KERNEL); + p->tx_ring = vzalloc(ipoib_sendq_size * sizeof *p->tx_ring); if (!p->tx_ring) { ipoib_warn(priv, "failed to allocate tx ring\n"); ret = -ENOMEM; goto err_tx; } - memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); p->qp = ipoib_cm_create_tx_qp(p->priv, p); if (IS_ERR(p->qp)) { @@ -1054,7 +1052,7 @@ err_id: ib_destroy_qp(p->qp); err_qp: p->qp = NULL; - kfree(p->tx_ring); + vfree(p->tx_ring); err_tx: return ret; } @@ -1105,7 +1103,7 @@ timeout: if (p->qp) ib_destroy_qp(p->qp); - kfree(p->tx_ring); + vfree(p->tx_ring); kfree(p); } @@ -1367,7 +1365,7 @@ static void ipoib_cm_create_srq(struct ipoib_dev_priv *priv, int max_sge) return; } - priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring, GFP_KERNEL); + priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring); if (!priv->cm.srq_ring) { printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n", priv->ca->name, ipoib_recvq_size); @@ -1376,7 +1374,6 @@ static void ipoib_cm_create_srq(struct ipoib_dev_priv *priv, int max_sge) return; } - memset(priv->cm.srq_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring); } int ipoib_cm_dev_init(struct ipoib_dev_priv *priv) diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c index f3a85f3a0cb7..fb1e34cfb215 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -799,13 +799,12 @@ ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port) goto out; } - priv->tx_ring = kzalloc(ipoib_sendq_size * sizeof *priv->tx_ring, GFP_KERNEL); + priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring); if (!priv->tx_ring) { printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n", ca->name, ipoib_sendq_size); goto out_rx_ring_cleanup; } - memset(priv->tx_ring, 0, ipoib_sendq_size * sizeof *priv->tx_ring); /* priv->tx_head, tx_tail & tx_outstanding are already 0 */ @@ -815,7 +814,7 @@ ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port) return 0; out_tx_ring_cleanup: - kfree(priv->tx_ring); + vfree(priv->tx_ring); out_rx_ring_cleanup: kfree(priv->rx_ring); @@ -866,7 +865,7 @@ ipoib_dev_cleanup(struct ipoib_dev_priv *priv) ipoib_ib_dev_cleanup(priv); kfree(priv->rx_ring); - kfree(priv->tx_ring); + vfree(priv->tx_ring); priv->rx_ring = NULL; priv->tx_ring = NULL;
