diff options
author | Joe Perches <joe@perches.com> | 2010-11-04 23:07:36 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2011-01-12 14:11:58 -0500 |
commit | 948579cd8c6ea7c8c98c52b79f4470952e182ebd (patch) | |
tree | 77e85adbdd07be8394fa60d08d3f1dbda3c67393 /drivers/infiniband | |
parent | 4162cf64973df51fc885825bc9ca4d055891c49f (diff) |
RDMA: Use vzalloc() to replace vmalloc()+memset(0)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/amso1100/c2_rnic.c | 5 | ||||
-rw-r--r-- | drivers/infiniband/hw/ehca/ipz_pt_fn.c | 5 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_driver.c | 3 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_file_ops.c | 11 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_init_chip.c | 5 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_init.c | 7 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_cm.c | 10 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 |
8 files changed, 15 insertions, 34 deletions
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c index 85cfae4cad71..8c81992fa6db 100644 --- a/drivers/infiniband/hw/amso1100/c2_rnic.c +++ b/drivers/infiniband/hw/amso1100/c2_rnic.c | |||
@@ -459,13 +459,12 @@ int __devinit c2_rnic_init(struct c2_dev *c2dev) | |||
459 | IB_DEVICE_MEM_WINDOW); | 459 | IB_DEVICE_MEM_WINDOW); |
460 | 460 | ||
461 | /* Allocate the qptr_array */ | 461 | /* Allocate the qptr_array */ |
462 | c2dev->qptr_array = vmalloc(C2_MAX_CQS * sizeof(void *)); | 462 | c2dev->qptr_array = vzalloc(C2_MAX_CQS * sizeof(void *)); |
463 | if (!c2dev->qptr_array) { | 463 | if (!c2dev->qptr_array) { |
464 | return -ENOMEM; | 464 | return -ENOMEM; |
465 | } | 465 | } |
466 | 466 | ||
467 | /* Inialize the qptr_array */ | 467 | /* Initialize the qptr_array */ |
468 | memset(c2dev->qptr_array, 0, C2_MAX_CQS * sizeof(void *)); | ||
469 | c2dev->qptr_array[0] = (void *) &c2dev->req_vq; | 468 | c2dev->qptr_array[0] = (void *) &c2dev->req_vq; |
470 | c2dev->qptr_array[1] = (void *) &c2dev->rep_vq; | 469 | c2dev->qptr_array[1] = (void *) &c2dev->rep_vq; |
471 | c2dev->qptr_array[2] = (void *) &c2dev->aeq; | 470 | c2dev->qptr_array[2] = (void *) &c2dev->aeq; |
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c index 1596e3085344..1898d6e7cce5 100644 --- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c +++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c | |||
@@ -222,15 +222,14 @@ int ipz_queue_ctor(struct ehca_pd *pd, struct ipz_queue *queue, | |||
222 | queue->small_page = NULL; | 222 | queue->small_page = NULL; |
223 | 223 | ||
224 | /* allocate queue page pointers */ | 224 | /* 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); |
226 | if (!queue->queue_pages) { | 226 | if (!queue->queue_pages) { |
227 | queue->queue_pages = vmalloc(nr_of_pages * sizeof(void *)); | 227 | queue->queue_pages = vzalloc(nr_of_pages * sizeof(void *)); |
228 | if (!queue->queue_pages) { | 228 | if (!queue->queue_pages) { |
229 | ehca_gen_err("Couldn't allocate queue page list"); | 229 | ehca_gen_err("Couldn't allocate queue page list"); |
230 | return 0; | 230 | return 0; |
231 | } | 231 | } |
232 | } | 232 | } |
233 | memset(queue->queue_pages, 0, nr_of_pages * sizeof(void *)); | ||
234 | 233 | ||
235 | /* allocate actual queue pages */ | 234 | /* allocate actual queue pages */ |
236 | if (is_small) { | 235 | if (is_small) { |
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index b33f0457a1ff..ae92da2d3f56 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c | |||
@@ -199,12 +199,11 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) | |||
199 | goto bail; | 199 | goto bail; |
200 | } | 200 | } |
201 | 201 | ||
202 | dd = vmalloc(sizeof(*dd)); | 202 | dd = vzalloc(sizeof(*dd)); |
203 | if (!dd) { | 203 | if (!dd) { |
204 | dd = ERR_PTR(-ENOMEM); | 204 | dd = ERR_PTR(-ENOMEM); |
205 | goto bail; | 205 | goto bail; |
206 | } | 206 | } |
207 | memset(dd, 0, sizeof(*dd)); | ||
208 | dd->ipath_unit = -1; | 207 | dd->ipath_unit = -1; |
209 | 208 | ||
210 | spin_lock_irqsave(&ipath_devs_lock, flags); | 209 | spin_lock_irqsave(&ipath_devs_lock, flags); |
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 9292a15ad7c4..6d4b29c4cd89 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -1530,7 +1530,7 @@ static int init_subports(struct ipath_devdata *dd, | |||
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | num_subports = uinfo->spu_subport_cnt; | 1532 | num_subports = uinfo->spu_subport_cnt; |
1533 | pd->subport_uregbase = vmalloc(PAGE_SIZE * num_subports); | 1533 | pd->subport_uregbase = vzalloc(PAGE_SIZE * num_subports); |
1534 | if (!pd->subport_uregbase) { | 1534 | if (!pd->subport_uregbase) { |
1535 | ret = -ENOMEM; | 1535 | ret = -ENOMEM; |
1536 | goto bail; | 1536 | goto bail; |
@@ -1538,13 +1538,13 @@ static int init_subports(struct ipath_devdata *dd, | |||
1538 | /* Note: pd->port_rcvhdrq_size isn't initialized yet. */ | 1538 | /* Note: pd->port_rcvhdrq_size isn't initialized yet. */ |
1539 | size = ALIGN(dd->ipath_rcvhdrcnt * dd->ipath_rcvhdrentsize * | 1539 | size = ALIGN(dd->ipath_rcvhdrcnt * dd->ipath_rcvhdrentsize * |
1540 | sizeof(u32), PAGE_SIZE) * num_subports; | 1540 | sizeof(u32), PAGE_SIZE) * num_subports; |
1541 | pd->subport_rcvhdr_base = vmalloc(size); | 1541 | pd->subport_rcvhdr_base = vzalloc(size); |
1542 | if (!pd->subport_rcvhdr_base) { | 1542 | if (!pd->subport_rcvhdr_base) { |
1543 | ret = -ENOMEM; | 1543 | ret = -ENOMEM; |
1544 | goto bail_ureg; | 1544 | goto bail_ureg; |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | pd->subport_rcvegrbuf = vmalloc(pd->port_rcvegrbuf_chunks * | 1547 | pd->subport_rcvegrbuf = vzalloc(pd->port_rcvegrbuf_chunks * |
1548 | pd->port_rcvegrbuf_size * | 1548 | pd->port_rcvegrbuf_size * |
1549 | num_subports); | 1549 | num_subports); |
1550 | if (!pd->subport_rcvegrbuf) { | 1550 | if (!pd->subport_rcvegrbuf) { |
@@ -1556,11 +1556,6 @@ static int init_subports(struct ipath_devdata *dd, | |||
1556 | pd->port_subport_id = uinfo->spu_subport_id; | 1556 | pd->port_subport_id = uinfo->spu_subport_id; |
1557 | pd->active_slaves = 1; | 1557 | pd->active_slaves = 1; |
1558 | set_bit(IPATH_PORT_MASTER_UNINIT, &pd->port_flag); | 1558 | 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); | ||
1564 | goto bail; | 1559 | goto bail; |
1565 | 1560 | ||
1566 | bail_rhdr: | 1561 | bail_rhdr: |
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c index 776938299e4c..fef0f4201257 100644 --- a/drivers/infiniband/hw/ipath/ipath_init_chip.c +++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c | |||
@@ -442,7 +442,7 @@ static void init_shadow_tids(struct ipath_devdata *dd) | |||
442 | struct page **pages; | 442 | struct page **pages; |
443 | dma_addr_t *addrs; | 443 | dma_addr_t *addrs; |
444 | 444 | ||
445 | pages = vmalloc(dd->ipath_cfgports * dd->ipath_rcvtidcnt * | 445 | pages = vzalloc(dd->ipath_cfgports * dd->ipath_rcvtidcnt * |
446 | sizeof(struct page *)); | 446 | sizeof(struct page *)); |
447 | if (!pages) { | 447 | if (!pages) { |
448 | ipath_dev_err(dd, "failed to allocate shadow page * " | 448 | ipath_dev_err(dd, "failed to allocate shadow page * " |
@@ -461,9 +461,6 @@ static void init_shadow_tids(struct ipath_devdata *dd) | |||
461 | return; | 461 | return; |
462 | } | 462 | } |
463 | 463 | ||
464 | memset(pages, 0, dd->ipath_cfgports * dd->ipath_rcvtidcnt * | ||
465 | sizeof(struct page *)); | ||
466 | |||
467 | dd->ipath_pageshadow = pages; | 464 | dd->ipath_pageshadow = pages; |
468 | dd->ipath_physshadow = addrs; | 465 | dd->ipath_physshadow = addrs; |
469 | } | 466 | } |
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 7896afbb9ce8..304bd8038541 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c | |||
@@ -270,23 +270,20 @@ static void init_shadow_tids(struct qib_devdata *dd) | |||
270 | struct page **pages; | 270 | struct page **pages; |
271 | dma_addr_t *addrs; | 271 | dma_addr_t *addrs; |
272 | 272 | ||
273 | pages = vmalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *)); | 273 | pages = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *)); |
274 | if (!pages) { | 274 | if (!pages) { |
275 | qib_dev_err(dd, "failed to allocate shadow page * " | 275 | qib_dev_err(dd, "failed to allocate shadow page * " |
276 | "array, no expected sends!\n"); | 276 | "array, no expected sends!\n"); |
277 | goto bail; | 277 | goto bail; |
278 | } | 278 | } |
279 | 279 | ||
280 | addrs = vmalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t)); | 280 | addrs = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t)); |
281 | if (!addrs) { | 281 | if (!addrs) { |
282 | qib_dev_err(dd, "failed to allocate shadow dma handle " | 282 | qib_dev_err(dd, "failed to allocate shadow dma handle " |
283 | "array, no expected sends!\n"); | 283 | "array, no expected sends!\n"); |
284 | goto bail_free; | 284 | goto bail_free; |
285 | } | 285 | } |
286 | 286 | ||
287 | memset(pages, 0, dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *)); | ||
288 | memset(addrs, 0, dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t)); | ||
289 | |||
290 | dd->pageshadow = pages; | 287 | dd->pageshadow = pages; |
291 | dd->physshadow = addrs; | 288 | dd->physshadow = addrs; |
292 | return; | 289 | return; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index c1c49f2d35b5..93d55806b967 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -352,15 +352,13 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i | |||
352 | int ret; | 352 | int ret; |
353 | int i; | 353 | int i; |
354 | 354 | ||
355 | rx->rx_ring = vmalloc(ipoib_recvq_size * sizeof *rx->rx_ring); | 355 | rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring); |
356 | if (!rx->rx_ring) { | 356 | if (!rx->rx_ring) { |
357 | printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n", | 357 | printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n", |
358 | priv->ca->name, ipoib_recvq_size); | 358 | priv->ca->name, ipoib_recvq_size); |
359 | return -ENOMEM; | 359 | return -ENOMEM; |
360 | } | 360 | } |
361 | 361 | ||
362 | memset(rx->rx_ring, 0, ipoib_recvq_size * sizeof *rx->rx_ring); | ||
363 | |||
364 | t = kmalloc(sizeof *t, GFP_KERNEL); | 362 | t = kmalloc(sizeof *t, GFP_KERNEL); |
365 | if (!t) { | 363 | if (!t) { |
366 | ret = -ENOMEM; | 364 | ret = -ENOMEM; |
@@ -1097,13 +1095,12 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | |||
1097 | struct ipoib_dev_priv *priv = netdev_priv(p->dev); | 1095 | struct ipoib_dev_priv *priv = netdev_priv(p->dev); |
1098 | int ret; | 1096 | int ret; |
1099 | 1097 | ||
1100 | p->tx_ring = vmalloc(ipoib_sendq_size * sizeof *p->tx_ring); | 1098 | p->tx_ring = vzalloc(ipoib_sendq_size * sizeof *p->tx_ring); |
1101 | if (!p->tx_ring) { | 1099 | if (!p->tx_ring) { |
1102 | ipoib_warn(priv, "failed to allocate tx ring\n"); | 1100 | ipoib_warn(priv, "failed to allocate tx ring\n"); |
1103 | ret = -ENOMEM; | 1101 | ret = -ENOMEM; |
1104 | goto err_tx; | 1102 | goto err_tx; |
1105 | } | 1103 | } |
1106 | memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); | ||
1107 | 1104 | ||
1108 | p->qp = ipoib_cm_create_tx_qp(p->dev, p); | 1105 | p->qp = ipoib_cm_create_tx_qp(p->dev, p); |
1109 | if (IS_ERR(p->qp)) { | 1106 | if (IS_ERR(p->qp)) { |
@@ -1521,7 +1518,7 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge) | |||
1521 | return; | 1518 | return; |
1522 | } | 1519 | } |
1523 | 1520 | ||
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); |
1525 | if (!priv->cm.srq_ring) { | 1522 | if (!priv->cm.srq_ring) { |
1526 | printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n", | 1523 | printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n", |
1527 | priv->ca->name, ipoib_recvq_size); | 1524 | priv->ca->name, ipoib_recvq_size); |
@@ -1530,7 +1527,6 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge) | |||
1530 | return; | 1527 | return; |
1531 | } | 1528 | } |
1532 | 1529 | ||
1533 | memset(priv->cm.srq_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring); | ||
1534 | } | 1530 | } |
1535 | 1531 | ||
1536 | int ipoib_cm_dev_init(struct net_device *dev) | 1532 | int ipoib_cm_dev_init(struct net_device *dev) |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 7a07a728fe0d..aca3b44f7aed 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -916,13 +916,12 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port) | |||
916 | goto out; | 916 | goto out; |
917 | } | 917 | } |
918 | 918 | ||
919 | priv->tx_ring = vmalloc(ipoib_sendq_size * sizeof *priv->tx_ring); | 919 | priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring); |
920 | if (!priv->tx_ring) { | 920 | if (!priv->tx_ring) { |
921 | printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n", | 921 | printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n", |
922 | ca->name, ipoib_sendq_size); | 922 | ca->name, ipoib_sendq_size); |
923 | goto out_rx_ring_cleanup; | 923 | goto out_rx_ring_cleanup; |
924 | } | 924 | } |
925 | memset(priv->tx_ring, 0, ipoib_sendq_size * sizeof *priv->tx_ring); | ||
926 | 925 | ||
927 | /* priv->tx_head, tx_tail & tx_outstanding are already 0 */ | 926 | /* priv->tx_head, tx_tail & tx_outstanding are already 0 */ |
928 | 927 | ||