diff options
-rw-r--r-- | drivers/net/ethernet/freescale/fec_main.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index b2793b91cc55..4cbebf3d80eb 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c | |||
@@ -386,7 +386,14 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
386 | */ | 386 | */ |
387 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr, | 387 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr, |
388 | FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); | 388 | FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); |
389 | 389 | if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) { | |
390 | bdp->cbd_bufaddr = 0; | ||
391 | fep->tx_skbuff[index] = NULL; | ||
392 | dev_kfree_skb_any(skb); | ||
393 | if (net_ratelimit()) | ||
394 | netdev_err(ndev, "Tx DMA memory map failed\n"); | ||
395 | return NETDEV_TX_OK; | ||
396 | } | ||
390 | /* Send it on its way. Tell FEC it's ready, interrupt when done, | 397 | /* Send it on its way. Tell FEC it's ready, interrupt when done, |
391 | * it's the last BD of the frame, and to put the CRC on the end. | 398 | * it's the last BD of the frame, and to put the CRC on the end. |
392 | */ | 399 | */ |
@@ -861,6 +868,7 @@ fec_enet_rx(struct net_device *ndev, int budget) | |||
861 | struct bufdesc_ex *ebdp = NULL; | 868 | struct bufdesc_ex *ebdp = NULL; |
862 | bool vlan_packet_rcvd = false; | 869 | bool vlan_packet_rcvd = false; |
863 | u16 vlan_tag; | 870 | u16 vlan_tag; |
871 | int index = 0; | ||
864 | 872 | ||
865 | #ifdef CONFIG_M532x | 873 | #ifdef CONFIG_M532x |
866 | flush_cache_all(); | 874 | flush_cache_all(); |
@@ -916,10 +924,15 @@ fec_enet_rx(struct net_device *ndev, int budget) | |||
916 | ndev->stats.rx_packets++; | 924 | ndev->stats.rx_packets++; |
917 | pkt_len = bdp->cbd_datlen; | 925 | pkt_len = bdp->cbd_datlen; |
918 | ndev->stats.rx_bytes += pkt_len; | 926 | ndev->stats.rx_bytes += pkt_len; |
919 | data = (__u8*)__va(bdp->cbd_bufaddr); | ||
920 | 927 | ||
921 | dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, | 928 | if (fep->bufdesc_ex) |
922 | FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE); | 929 | index = (struct bufdesc_ex *)bdp - |
930 | (struct bufdesc_ex *)fep->rx_bd_base; | ||
931 | else | ||
932 | index = bdp - fep->rx_bd_base; | ||
933 | data = fep->rx_skbuff[index]->data; | ||
934 | dma_sync_single_for_cpu(&fep->pdev->dev, bdp->cbd_bufaddr, | ||
935 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); | ||
923 | 936 | ||
924 | if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) | 937 | if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) |
925 | swap_buffer(data, pkt_len); | 938 | swap_buffer(data, pkt_len); |
@@ -999,8 +1012,8 @@ fec_enet_rx(struct net_device *ndev, int budget) | |||
999 | napi_gro_receive(&fep->napi, skb); | 1012 | napi_gro_receive(&fep->napi, skb); |
1000 | } | 1013 | } |
1001 | 1014 | ||
1002 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, data, | 1015 | dma_sync_single_for_device(&fep->pdev->dev, bdp->cbd_bufaddr, |
1003 | FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE); | 1016 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); |
1004 | rx_processing_done: | 1017 | rx_processing_done: |
1005 | /* Clear the status flags for this buffer */ | 1018 | /* Clear the status flags for this buffer */ |
1006 | status &= ~BD_ENET_RX_STATS; | 1019 | status &= ~BD_ENET_RX_STATS; |
@@ -1719,6 +1732,12 @@ static int fec_enet_alloc_buffers(struct net_device *ndev) | |||
1719 | 1732 | ||
1720 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, skb->data, | 1733 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, skb->data, |
1721 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); | 1734 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); |
1735 | if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) { | ||
1736 | fec_enet_free_buffers(ndev); | ||
1737 | if (net_ratelimit()) | ||
1738 | netdev_err(ndev, "Rx DMA memory map failed\n"); | ||
1739 | return -ENOMEM; | ||
1740 | } | ||
1722 | bdp->cbd_sc = BD_ENET_RX_EMPTY; | 1741 | bdp->cbd_sc = BD_ENET_RX_EMPTY; |
1723 | 1742 | ||
1724 | if (fep->bufdesc_ex) { | 1743 | if (fep->bufdesc_ex) { |