Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f9061d2 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller
Browse files

drivers:net: dma_alloc_coherent: use __GFP_ZERO instead of memset(, 0)



Reduce the number of calls required to alloc
a zeroed block of memory.

Trivially reduces overall object size.

Other changes around these removals
o Neaten call argument alignment
o Remove an unnecessary OOM message after dma_alloc_coherent failure
o Remove unnecessary gfp_t stack variable

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7f9421c2
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -1466,25 +1466,21 @@ static int greth_of_probe(struct platform_device *ofdev)
	/* Allocate TX descriptor ring in coherent memory */
	greth->tx_bd_base = dma_alloc_coherent(greth->dev, 1024,
					       &greth->tx_bd_base_phys,
					       GFP_KERNEL);
					       GFP_KERNEL | __GFP_ZERO);
	if (!greth->tx_bd_base) {
		err = -ENOMEM;
		goto error3;
	}

	memset(greth->tx_bd_base, 0, 1024);

	/* Allocate RX descriptor ring in coherent memory */
	greth->rx_bd_base = dma_alloc_coherent(greth->dev, 1024,
					       &greth->rx_bd_base_phys,
					       GFP_KERNEL);
					       GFP_KERNEL | __GFP_ZERO);
	if (!greth->rx_bd_base) {
		err = -ENOMEM;
		goto error4;
	}

	memset(greth->rx_bd_base, 0, 1024);

	/* Get MAC address from: module param, OF property or ID prom */
	for (i = 0; i < 6; i++) {
		if (macaddr[i] != 0)
+4 −4
Original line number Diff line number Diff line
@@ -862,25 +862,25 @@ static int bcm_enet_open(struct net_device *dev)

	/* allocate rx dma ring */
	size = priv->rx_ring_size * sizeof(struct bcm_enet_desc);
	p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL);
	p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma,
			       GFP_KERNEL | __GFP_ZERO);
	if (!p) {
		ret = -ENOMEM;
		goto out_freeirq_tx;
	}

	memset(p, 0, size);
	priv->rx_desc_alloc_size = size;
	priv->rx_desc_cpu = p;

	/* allocate tx dma ring */
	size = priv->tx_ring_size * sizeof(struct bcm_enet_desc);
	p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL);
	p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma,
			       GFP_KERNEL | __GFP_ZERO);
	if (!p) {
		ret = -ENOMEM;
		goto out_free_rx_ring;
	}

	memset(p, 0, size);
	priv->tx_desc_alloc_size = size;
	priv->tx_desc_cpu = p;

+2 −3
Original line number Diff line number Diff line
@@ -854,12 +854,11 @@ bnx2_alloc_mem(struct bnx2 *bp)
				sizeof(struct statistics_block);

	status_blk = dma_alloc_coherent(&bp->pdev->dev, bp->status_stats_size,
					&bp->status_blk_mapping, GFP_KERNEL);
					&bp->status_blk_mapping,
					GFP_KERNEL | __GFP_ZERO);
	if (status_blk == NULL)
		goto alloc_mem_err;

	memset(status_blk, 0, bp->status_stats_size);

	bnapi = &bp->bnx2_napi[0];
	bnapi->status_blk.msi = status_blk;
	bnapi->hw_tx_cons_ptr =
+3 −6
Original line number Diff line number Diff line
@@ -1947,11 +1947,8 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
			    bool is_pf);

#define BNX2X_ILT_ZALLOC(x, y, size)				\
	do { \
		x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
		if (x) \
			memset(x, 0, size); \
	} while (0)
	x = dma_alloc_coherent(&bp->pdev->dev, size, y,		\
			       GFP_KERNEL | __GFP_ZERO)

#define BNX2X_ILT_FREE(x, y, size) \
	do { \
+7 −7
Original line number Diff line number Diff line
@@ -52,10 +52,10 @@ extern int int_mode;

#define BNX2X_PCI_ALLOC(x, y, size)				\
do {								\
		x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
	x = dma_alloc_coherent(&bp->pdev->dev, size, y,		\
			       GFP_KERNEL | __GFP_ZERO);	\
	if (x == NULL)						\
		goto alloc_mem_err;				\
		memset((void *)x, 0, size); \
} while (0)

#define BNX2X_ALLOC(x, size) \
Loading