summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFugang Duan <B38611@freescale.com>2011-12-21 18:32:11 +0800
committerFugang Duan <B38611@freescale.com>2011-12-27 14:33:22 +0800
commit6c3f6f9daa4d81c92c11384963ae3efa98b7aa3d (patch)
tree62cf76b007ccaa1183cc6b869b870facc05782e3
parentff14e19f6112ae7d5358bde83c021331c1601fa6 (diff)
ENGR00170784 - FEC : dma skb buffer map is not used rightly.
Enable "CONFIG_DMA_API_DEBUG" in kernel, and system print: DMA-API: device driver tries to free DMA memory it has not allocated [device address=0x0000000046688020]...[<80222494>] (debug_dma_unmap_page+0x8c/0x98) from [<802a36a0>] (fec_enet_interrupt+0x430/0x5ac) Correct the usage of "dma_map_single" function. Signed-off-by: Fugang Duan <B38611@freescale.com>
-rw-r--r--drivers/net/fec.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 3ca487da1272..ec5070626824 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -444,7 +444,9 @@ fec_enet_tx(struct net_device *dev)
if (bdp == fep->cur_tx && fep->tx_full == 0)
break;
- dma_unmap_single(&dev->dev, bdp->cbd_bufaddr, FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
+ if (bdp->cbd_bufaddr)
+ dma_unmap_single(&dev->dev, bdp->cbd_bufaddr,
+ FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
bdp->cbd_bufaddr = 0;
skb = fep->tx_skbuff[fep->skb_dirty];
@@ -584,8 +586,9 @@ fec_enet_rx(struct net_device *dev)
dev->stats.rx_bytes += pkt_len;
data = (__u8*)__va(bdp->cbd_bufaddr);
- dma_unmap_single(NULL, bdp->cbd_bufaddr, bdp->cbd_datlen,
- DMA_FROM_DEVICE);
+ if (bdp->cbd_bufaddr)
+ dma_unmap_single(&dev->dev, bdp->cbd_bufaddr,
+ FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME)
swap_buffer(data, pkt_len);
@@ -612,8 +615,8 @@ fec_enet_rx(struct net_device *dev)
netif_rx(skb);
}
- bdp->cbd_bufaddr = dma_map_single(NULL, data, bdp->cbd_datlen,
- DMA_FROM_DEVICE);
+ bdp->cbd_bufaddr = dma_map_single(&dev->dev, data,
+ FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE);
rx_processing_done:
/* Clear the status flags for this buffer */
status &= ~BD_ENET_RX_STATS;
@@ -1096,7 +1099,6 @@ fec_enet_open(struct net_device *dev)
/* I should reset the ring buffers here, but I don't yet know
* a simple way to do that.
*/
-
if (!clk_get_usecount(fep->clk))
clk_enable(fep->clk);
ret = fec_enet_alloc_buffers(dev);
@@ -1296,6 +1298,7 @@ static int fec_enet_init(struct net_device *dev)
/* Initialize the BD for every fragment in the page. */
bdp->cbd_sc = 0;
+ bdp->cbd_bufaddr = 0;
bdp++;
}