Skip to content

Commit 948579c

Browse files
JoePerchesRoland Dreier
authored andcommitted
RDMA: Use vzalloc() to replace vmalloc()+memset(0)
Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 4162cf6 commit 948579c

File tree

8 files changed

+15
-34
lines changed

8 files changed

+15
-34
lines changed

drivers/infiniband/hw/amso1100/c2_rnic.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,12 @@ int __devinit c2_rnic_init(struct c2_dev *c2dev)
459459
IB_DEVICE_MEM_WINDOW);
460460

461461
/* Allocate the qptr_array */
462-
c2dev->qptr_array = vmalloc(C2_MAX_CQS * sizeof(void *));
462+
c2dev->qptr_array = vzalloc(C2_MAX_CQS * sizeof(void *));
463463
if (!c2dev->qptr_array) {
464464
return -ENOMEM;
465465
}
466466

467-
/* Inialize the qptr_array */
468-
memset(c2dev->qptr_array, 0, C2_MAX_CQS * sizeof(void *));
467+
/* Initialize the qptr_array */
469468
c2dev->qptr_array[0] = (void *) &c2dev->req_vq;
470469
c2dev->qptr_array[1] = (void *) &c2dev->rep_vq;
471470
c2dev->qptr_array[2] = (void *) &c2dev->aeq;

drivers/infiniband/hw/ehca/ipz_pt_fn.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,14 @@ int ipz_queue_ctor(struct ehca_pd *pd, struct ipz_queue *queue,
222222
queue->small_page = NULL;
223223

224224
/* allocate queue page pointers */
225-
queue->queue_pages = kmalloc(nr_of_pages * sizeof(void *), GFP_KERNEL);
225+
queue->queue_pages = kzalloc(nr_of_pages * sizeof(void *), GFP_KERNEL);
226226
if (!queue->queue_pages) {
227-
queue->queue_pages = vmalloc(nr_of_pages * sizeof(void *));
227+
queue->queue_pages = vzalloc(nr_of_pages * sizeof(void *));
228228
if (!queue->queue_pages) {
229229
ehca_gen_err("Couldn't allocate queue page list");
230230
return 0;
231231
}
232232
}
233-
memset(queue->queue_pages, 0, nr_of_pages * sizeof(void *));
234233

235234
/* allocate actual queue pages */
236235
if (is_small) {

drivers/infiniband/hw/ipath/ipath_driver.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,11 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
199199
goto bail;
200200
}
201201

202-
dd = vmalloc(sizeof(*dd));
202+
dd = vzalloc(sizeof(*dd));
203203
if (!dd) {
204204
dd = ERR_PTR(-ENOMEM);
205205
goto bail;
206206
}
207-
memset(dd, 0, sizeof(*dd));
208207
dd->ipath_unit = -1;
209208

210209
spin_lock_irqsave(&ipath_devs_lock, flags);

drivers/infiniband/hw/ipath/ipath_file_ops.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,21 +1530,21 @@ static int init_subports(struct ipath_devdata *dd,
15301530
}
15311531

15321532
num_subports = uinfo->spu_subport_cnt;
1533-
pd->subport_uregbase = vmalloc(PAGE_SIZE * num_subports);
1533+
pd->subport_uregbase = vzalloc(PAGE_SIZE * num_subports);
15341534
if (!pd->subport_uregbase) {
15351535
ret = -ENOMEM;
15361536
goto bail;
15371537
}
15381538
/* Note: pd->port_rcvhdrq_size isn't initialized yet. */
15391539
size = ALIGN(dd->ipath_rcvhdrcnt * dd->ipath_rcvhdrentsize *
15401540
sizeof(u32), PAGE_SIZE) * num_subports;
1541-
pd->subport_rcvhdr_base = vmalloc(size);
1541+
pd->subport_rcvhdr_base = vzalloc(size);
15421542
if (!pd->subport_rcvhdr_base) {
15431543
ret = -ENOMEM;
15441544
goto bail_ureg;
15451545
}
15461546

1547-
pd->subport_rcvegrbuf = vmalloc(pd->port_rcvegrbuf_chunks *
1547+
pd->subport_rcvegrbuf = vzalloc(pd->port_rcvegrbuf_chunks *
15481548
pd->port_rcvegrbuf_size *
15491549
num_subports);
15501550
if (!pd->subport_rcvegrbuf) {
@@ -1556,11 +1556,6 @@ static int init_subports(struct ipath_devdata *dd,
15561556
pd->port_subport_id = uinfo->spu_subport_id;
15571557
pd->active_slaves = 1;
15581558
set_bit(IPATH_PORT_MASTER_UNINIT, &pd->port_flag);
1559-
memset(pd->subport_uregbase, 0, PAGE_SIZE * num_subports);
1560-
memset(pd->subport_rcvhdr_base, 0, size);
1561-
memset(pd->subport_rcvegrbuf, 0, pd->port_rcvegrbuf_chunks *
1562-
pd->port_rcvegrbuf_size *
1563-
num_subports);
15641559
goto bail;
15651560

15661561
bail_rhdr:

drivers/infiniband/hw/ipath/ipath_init_chip.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static void init_shadow_tids(struct ipath_devdata *dd)
442442
struct page **pages;
443443
dma_addr_t *addrs;
444444

445-
pages = vmalloc(dd->ipath_cfgports * dd->ipath_rcvtidcnt *
445+
pages = vzalloc(dd->ipath_cfgports * dd->ipath_rcvtidcnt *
446446
sizeof(struct page *));
447447
if (!pages) {
448448
ipath_dev_err(dd, "failed to allocate shadow page * "
@@ -461,9 +461,6 @@ static void init_shadow_tids(struct ipath_devdata *dd)
461461
return;
462462
}
463463

464-
memset(pages, 0, dd->ipath_cfgports * dd->ipath_rcvtidcnt *
465-
sizeof(struct page *));
466-
467464
dd->ipath_pageshadow = pages;
468465
dd->ipath_physshadow = addrs;
469466
}

drivers/infiniband/hw/qib/qib_init.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,23 +270,20 @@ static void init_shadow_tids(struct qib_devdata *dd)
270270
struct page **pages;
271271
dma_addr_t *addrs;
272272

273-
pages = vmalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
273+
pages = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
274274
if (!pages) {
275275
qib_dev_err(dd, "failed to allocate shadow page * "
276276
"array, no expected sends!\n");
277277
goto bail;
278278
}
279279

280-
addrs = vmalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
280+
addrs = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
281281
if (!addrs) {
282282
qib_dev_err(dd, "failed to allocate shadow dma handle "
283283
"array, no expected sends!\n");
284284
goto bail_free;
285285
}
286286

287-
memset(pages, 0, dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
288-
memset(addrs, 0, dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
289-
290287
dd->pageshadow = pages;
291288
dd->physshadow = addrs;
292289
return;

drivers/infiniband/ulp/ipoib/ipoib_cm.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,13 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
352352
int ret;
353353
int i;
354354

355-
rx->rx_ring = vmalloc(ipoib_recvq_size * sizeof *rx->rx_ring);
355+
rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring);
356356
if (!rx->rx_ring) {
357357
printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n",
358358
priv->ca->name, ipoib_recvq_size);
359359
return -ENOMEM;
360360
}
361361

362-
memset(rx->rx_ring, 0, ipoib_recvq_size * sizeof *rx->rx_ring);
363-
364362
t = kmalloc(sizeof *t, GFP_KERNEL);
365363
if (!t) {
366364
ret = -ENOMEM;
@@ -1097,13 +1095,12 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
10971095
struct ipoib_dev_priv *priv = netdev_priv(p->dev);
10981096
int ret;
10991097

1100-
p->tx_ring = vmalloc(ipoib_sendq_size * sizeof *p->tx_ring);
1098+
p->tx_ring = vzalloc(ipoib_sendq_size * sizeof *p->tx_ring);
11011099
if (!p->tx_ring) {
11021100
ipoib_warn(priv, "failed to allocate tx ring\n");
11031101
ret = -ENOMEM;
11041102
goto err_tx;
11051103
}
1106-
memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring);
11071104

11081105
p->qp = ipoib_cm_create_tx_qp(p->dev, p);
11091106
if (IS_ERR(p->qp)) {
@@ -1521,7 +1518,7 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
15211518
return;
15221519
}
15231520

1524-
priv->cm.srq_ring = vmalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
1521+
priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
15251522
if (!priv->cm.srq_ring) {
15261523
printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n",
15271524
priv->ca->name, ipoib_recvq_size);
@@ -1530,7 +1527,6 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
15301527
return;
15311528
}
15321529

1533-
memset(priv->cm.srq_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring);
15341530
}
15351531

15361532
int ipoib_cm_dev_init(struct net_device *dev)

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,12 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
916916
goto out;
917917
}
918918

919-
priv->tx_ring = vmalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
919+
priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
920920
if (!priv->tx_ring) {
921921
printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n",
922922
ca->name, ipoib_sendq_size);
923923
goto out_rx_ring_cleanup;
924924
}
925-
memset(priv->tx_ring, 0, ipoib_sendq_size * sizeof *priv->tx_ring);
926925

927926
/* priv->tx_head, tx_tail & tx_outstanding are already 0 */
928927

0 commit comments

Comments
 (0)