diff options
author | Ioana Radulescu <ruxandra.radulescu@freescale.com> | 2013-07-24 14:37:15 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-07-31 21:49:34 (GMT) |
commit | 85699c3e9fedd9393a5405015f958cf23c6d5997 (patch) | |
tree | 333b59a976f36782d1fb095446c90e383101315c /drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c | |
parent | e18e797c3c42e6412808dd07b4cc757455b1b2b6 (diff) | |
download | linux-fsl-qoriq-85699c3e9fedd9393a5405015f958cf23c6d5997.tar.xz |
dpaa_eth: Fix size of DMA mappings
Use the correct buffer size for DMA mappings on Tx path, otherwise
we risk mapping too little if we have an MTU larger than the size
of the default buffer pool.
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@freescale.com>
Change-Id: Id197e3284a884fd417c62e13af8cb9688a2f1b8f
Reviewed-on: http://git.am.freescale.net:8181/3654
Reviewed-by: Bucur Madalin-Cristian-B32716 <madalin.bucur@freescale.com>
Reviewed-by: Hamciuc Bogdan-BHAMCIU1 <bogdan.hamciuc@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c')
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c index 4e4f2ac..bc90d29 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c @@ -241,7 +241,7 @@ struct sk_buff *_dpa_cleanup_tx_fd(const struct dpa_priv_s *priv, BUG_ON(sgt[i].extension); dma_unmap_page(dpa_bp->dev, sgt[i].addr, - dpa_bp->size, dma_dir); + sgt[i].length, dma_dir); } /* @@ -671,7 +671,9 @@ no_recycle: fd->format = qm_fd_contig; fd->length20 = skb->len; - addr = dma_map_single(dpa_bp->dev, skbh, dpa_bp->size, dma_dir); + /* Map the entire buffer size that may be seen by FMan, but no more */ + addr = dma_map_single(dpa_bp->dev, skbh, + skb_end_pointer(skb) - (unsigned char *)skbh, dma_dir); if (unlikely(dma_mapping_error(dpa_bp->dev, addr))) { if (netif_msg_tx_err(priv) && net_ratelimit()) netdev_err(net_dev, "dma_map_single() failed\n"); @@ -750,7 +752,7 @@ static int __hot skb_to_sg_fd(struct dpa_priv_s *priv, sgt[i].final = 0; BUG_ON(!skb_frag_page(frag)); - addr = skb_frag_dma_map(dpa_bp->dev, frag, 0, dpa_bp->size, + addr = skb_frag_dma_map(dpa_bp->dev, frag, 0, sgt[i].length, dma_dir); if (unlikely(dma_mapping_error(dpa_bp->dev, addr))) { dev_err(dpa_bp->dev, "DMA mapping failed"); @@ -772,7 +774,8 @@ static int __hot skb_to_sg_fd(struct dpa_priv_s *priv, skbh = (struct sk_buff **)buffer_start; *skbh = skb; - addr = dma_map_single(dpa_bp->dev, buffer_start, dpa_bp->size, dma_dir); + addr = dma_map_single(dpa_bp->dev, buffer_start, + skb_end_pointer(skb) - (unsigned char *)buffer_start, dma_dir); if (unlikely(dma_mapping_error(dpa_bp->dev, addr))) { dev_err(dpa_bp->dev, "DMA mapping failed"); err = -EINVAL; @@ -787,7 +790,7 @@ sgt_map_failed: sg_map_failed: for (j = 0; j < i; j++) dma_unmap_page(dpa_bp->dev, qm_sg_addr(&sgt[j]), - dpa_bp->size, dma_dir); + sgt[j].length, dma_dir); sg0_map_failed: csum_failed: put_page(virt_to_head_page(sgt_buf)); |