Commit 4247ef02 authored by Cai Huoqing's avatar Cai Huoqing Committed by David S. Miller

ibmveth: Use dma_alloc_coherent() instead of kmalloc/dma_map_single()

Replacing kmalloc/kfree/dma_map_single/dma_unmap_single()
with dma_alloc_coherent/dma_free_coherent() helps to reduce
code size, and simplify the code, and coherent DMA will not
clear the cache every time.
Signed-off-by: default avatarCai Huoqing <caihuoqing@baidu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f947fcaf
...@@ -605,17 +605,13 @@ static int ibmveth_open(struct net_device *netdev) ...@@ -605,17 +605,13 @@ static int ibmveth_open(struct net_device *netdev)
} }
rc = -ENOMEM; rc = -ENOMEM;
adapter->bounce_buffer =
kmalloc(netdev->mtu + IBMVETH_BUFF_OH, GFP_KERNEL);
if (!adapter->bounce_buffer)
goto out_free_irq;
adapter->bounce_buffer_dma = adapter->bounce_buffer = dma_alloc_coherent(&adapter->vdev->dev,
dma_map_single(&adapter->vdev->dev, adapter->bounce_buffer, netdev->mtu + IBMVETH_BUFF_OH,
netdev->mtu + IBMVETH_BUFF_OH, DMA_BIDIRECTIONAL); &adapter->bounce_buffer_dma, GFP_KERNEL);
if (dma_mapping_error(dev, adapter->bounce_buffer_dma)) { if (!adapter->bounce_buffer) {
netdev_err(netdev, "unable to map bounce buffer\n"); netdev_err(netdev, "unable to alloc bounce buffer\n");
goto out_free_bounce_buffer; goto out_free_irq;
} }
netdev_dbg(netdev, "initial replenish cycle\n"); netdev_dbg(netdev, "initial replenish cycle\n");
...@@ -627,8 +623,6 @@ static int ibmveth_open(struct net_device *netdev) ...@@ -627,8 +623,6 @@ static int ibmveth_open(struct net_device *netdev)
return 0; return 0;
out_free_bounce_buffer:
kfree(adapter->bounce_buffer);
out_free_irq: out_free_irq:
free_irq(netdev->irq, netdev); free_irq(netdev->irq, netdev);
out_free_buffer_pools: out_free_buffer_pools:
...@@ -702,10 +696,9 @@ static int ibmveth_close(struct net_device *netdev) ...@@ -702,10 +696,9 @@ static int ibmveth_close(struct net_device *netdev)
ibmveth_free_buffer_pool(adapter, ibmveth_free_buffer_pool(adapter,
&adapter->rx_buff_pool[i]); &adapter->rx_buff_pool[i]);
dma_unmap_single(&adapter->vdev->dev, adapter->bounce_buffer_dma, dma_free_coherent(&adapter->vdev->dev,
adapter->netdev->mtu + IBMVETH_BUFF_OH, adapter->netdev->mtu + IBMVETH_BUFF_OH,
DMA_BIDIRECTIONAL); adapter->bounce_buffer, adapter->bounce_buffer_dma);
kfree(adapter->bounce_buffer);
netdev_dbg(netdev, "close complete\n"); netdev_dbg(netdev, "close complete\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment