diff options
author | Claudiu Manoil <claudiu.manoil@freescale.com> | 2013-02-14 00:00:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-14 13:32:24 -0500 |
commit | 369ec162b30e34c29bef8ec5ce32c40d5697fd64 (patch) | |
tree | 4fc74e93960c792f3c057a9b92ea7d066e1aacb4 | |
parent | 41a2060976ca879a68108ffb181dc429d556adce (diff) |
gianfar: Add device ref (dev) in gfar_private
Use device pointer (dev) to simplify the code and to
avoid double indirections, especially on the hot path.
Basically, instead of accessing priv to get the ofdev
reference and then accessing the ofdev structure to
dereference the needed dev pointer, we will get the
dev pointer directly from priv.
The dev pointer is required on the hot path, see gfar_new_rxbdp
or gfar_clean_rx_ring (or xmit), and this patch makes
it available directly from priv's 1st cacheline.
This change is reflected at asm level too, taking (the hot)
gfar_new_rxbdp():
initial version -
18c0: 7c 7e 1b 78 mr r30,r3
18d0: 81 69 04 3c lwz r11,1084(r9)
18d8: 34 6b 00 10 addic. r3,r11,16
18dc: 41 82 00 08 beq- 18e4
patched version -
18d0: 80 69 04 38 lwz r3,1080(r9)
18d8: 2f 83 00 00 cmpwi cr7,r3,0
18dc: 41 9e 00 08 beq- cr7,18e4
Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 25 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.h | 1 |
2 files changed, 14 insertions, 12 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 2c6b5694b3f0..592d297b9eda 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -231,7 +231,7 @@ static int gfar_alloc_skb_resources(struct net_device *ndev) | |||
231 | dma_addr_t addr; | 231 | dma_addr_t addr; |
232 | int i, j, k; | 232 | int i, j, k; |
233 | struct gfar_private *priv = netdev_priv(ndev); | 233 | struct gfar_private *priv = netdev_priv(ndev); |
234 | struct device *dev = &priv->ofdev->dev; | 234 | struct device *dev = priv->dev; |
235 | struct gfar_priv_tx_q *tx_queue = NULL; | 235 | struct gfar_priv_tx_q *tx_queue = NULL; |
236 | struct gfar_priv_rx_q *rx_queue = NULL; | 236 | struct gfar_priv_rx_q *rx_queue = NULL; |
237 | 237 | ||
@@ -1000,6 +1000,7 @@ static int gfar_probe(struct platform_device *ofdev) | |||
1000 | priv = netdev_priv(dev); | 1000 | priv = netdev_priv(dev); |
1001 | priv->ndev = dev; | 1001 | priv->ndev = dev; |
1002 | priv->ofdev = ofdev; | 1002 | priv->ofdev = ofdev; |
1003 | priv->dev = &ofdev->dev; | ||
1003 | SET_NETDEV_DEV(dev, &ofdev->dev); | 1004 | SET_NETDEV_DEV(dev, &ofdev->dev); |
1004 | 1005 | ||
1005 | spin_lock_init(&priv->bflock); | 1006 | spin_lock_init(&priv->bflock); |
@@ -1713,13 +1714,13 @@ static void free_skb_tx_queue(struct gfar_priv_tx_q *tx_queue) | |||
1713 | if (!tx_queue->tx_skbuff[i]) | 1714 | if (!tx_queue->tx_skbuff[i]) |
1714 | continue; | 1715 | continue; |
1715 | 1716 | ||
1716 | dma_unmap_single(&priv->ofdev->dev, txbdp->bufPtr, | 1717 | dma_unmap_single(priv->dev, txbdp->bufPtr, |
1717 | txbdp->length, DMA_TO_DEVICE); | 1718 | txbdp->length, DMA_TO_DEVICE); |
1718 | txbdp->lstatus = 0; | 1719 | txbdp->lstatus = 0; |
1719 | for (j = 0; j < skb_shinfo(tx_queue->tx_skbuff[i])->nr_frags; | 1720 | for (j = 0; j < skb_shinfo(tx_queue->tx_skbuff[i])->nr_frags; |
1720 | j++) { | 1721 | j++) { |
1721 | txbdp++; | 1722 | txbdp++; |
1722 | dma_unmap_page(&priv->ofdev->dev, txbdp->bufPtr, | 1723 | dma_unmap_page(priv->dev, txbdp->bufPtr, |
1723 | txbdp->length, DMA_TO_DEVICE); | 1724 | txbdp->length, DMA_TO_DEVICE); |
1724 | } | 1725 | } |
1725 | txbdp++; | 1726 | txbdp++; |
@@ -1740,8 +1741,8 @@ static void free_skb_rx_queue(struct gfar_priv_rx_q *rx_queue) | |||
1740 | 1741 | ||
1741 | for (i = 0; i < rx_queue->rx_ring_size; i++) { | 1742 | for (i = 0; i < rx_queue->rx_ring_size; i++) { |
1742 | if (rx_queue->rx_skbuff[i]) { | 1743 | if (rx_queue->rx_skbuff[i]) { |
1743 | dma_unmap_single(&priv->ofdev->dev, | 1744 | dma_unmap_single(priv->dev, rxbdp->bufPtr, |
1744 | rxbdp->bufPtr, priv->rx_buffer_size, | 1745 | priv->rx_buffer_size, |
1745 | DMA_FROM_DEVICE); | 1746 | DMA_FROM_DEVICE); |
1746 | dev_kfree_skb_any(rx_queue->rx_skbuff[i]); | 1747 | dev_kfree_skb_any(rx_queue->rx_skbuff[i]); |
1747 | rx_queue->rx_skbuff[i] = NULL; | 1748 | rx_queue->rx_skbuff[i] = NULL; |
@@ -1780,7 +1781,7 @@ static void free_skb_resources(struct gfar_private *priv) | |||
1780 | free_skb_rx_queue(rx_queue); | 1781 | free_skb_rx_queue(rx_queue); |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | dma_free_coherent(&priv->ofdev->dev, | 1784 | dma_free_coherent(priv->dev, |
1784 | sizeof(struct txbd8) * priv->total_tx_ring_size + | 1785 | sizeof(struct txbd8) * priv->total_tx_ring_size + |
1785 | sizeof(struct rxbd8) * priv->total_rx_ring_size, | 1786 | sizeof(struct rxbd8) * priv->total_rx_ring_size, |
1786 | priv->tx_queue[0]->tx_bd_base, | 1787 | priv->tx_queue[0]->tx_bd_base, |
@@ -2160,7 +2161,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2160 | if (i == nr_frags - 1) | 2161 | if (i == nr_frags - 1) |
2161 | lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT); | 2162 | lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT); |
2162 | 2163 | ||
2163 | bufaddr = skb_frag_dma_map(&priv->ofdev->dev, | 2164 | bufaddr = skb_frag_dma_map(priv->dev, |
2164 | &skb_shinfo(skb)->frags[i], | 2165 | &skb_shinfo(skb)->frags[i], |
2165 | 0, | 2166 | 0, |
2166 | length, | 2167 | length, |
@@ -2212,7 +2213,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2212 | lstatus |= BD_LFLAG(TXBD_TOE); | 2213 | lstatus |= BD_LFLAG(TXBD_TOE); |
2213 | } | 2214 | } |
2214 | 2215 | ||
2215 | txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data, | 2216 | txbdp_start->bufPtr = dma_map_single(priv->dev, skb->data, |
2216 | skb_headlen(skb), DMA_TO_DEVICE); | 2217 | skb_headlen(skb), DMA_TO_DEVICE); |
2217 | 2218 | ||
2218 | /* If time stamping is requested one additional TxBD must be set up. The | 2219 | /* If time stamping is requested one additional TxBD must be set up. The |
@@ -2525,7 +2526,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) | |||
2525 | } else | 2526 | } else |
2526 | buflen = bdp->length; | 2527 | buflen = bdp->length; |
2527 | 2528 | ||
2528 | dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr, | 2529 | dma_unmap_single(priv->dev, bdp->bufPtr, |
2529 | buflen, DMA_TO_DEVICE); | 2530 | buflen, DMA_TO_DEVICE); |
2530 | 2531 | ||
2531 | if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { | 2532 | if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { |
@@ -2544,7 +2545,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) | |||
2544 | bdp = next_txbd(bdp, base, tx_ring_size); | 2545 | bdp = next_txbd(bdp, base, tx_ring_size); |
2545 | 2546 | ||
2546 | for (i = 0; i < frags; i++) { | 2547 | for (i = 0; i < frags; i++) { |
2547 | dma_unmap_page(&priv->ofdev->dev, bdp->bufPtr, | 2548 | dma_unmap_page(priv->dev, bdp->bufPtr, |
2548 | bdp->length, DMA_TO_DEVICE); | 2549 | bdp->length, DMA_TO_DEVICE); |
2549 | bdp->lstatus &= BD_LFLAG(TXBD_WRAP); | 2550 | bdp->lstatus &= BD_LFLAG(TXBD_WRAP); |
2550 | bdp = next_txbd(bdp, base, tx_ring_size); | 2551 | bdp = next_txbd(bdp, base, tx_ring_size); |
@@ -2610,7 +2611,7 @@ static void gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp, | |||
2610 | struct gfar_private *priv = netdev_priv(dev); | 2611 | struct gfar_private *priv = netdev_priv(dev); |
2611 | dma_addr_t buf; | 2612 | dma_addr_t buf; |
2612 | 2613 | ||
2613 | buf = dma_map_single(&priv->ofdev->dev, skb->data, | 2614 | buf = dma_map_single(priv->dev, skb->data, |
2614 | priv->rx_buffer_size, DMA_FROM_DEVICE); | 2615 | priv->rx_buffer_size, DMA_FROM_DEVICE); |
2615 | gfar_init_rxbdp(rx_queue, bdp, buf); | 2616 | gfar_init_rxbdp(rx_queue, bdp, buf); |
2616 | } | 2617 | } |
@@ -2775,7 +2776,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) | |||
2775 | 2776 | ||
2776 | skb = rx_queue->rx_skbuff[rx_queue->skb_currx]; | 2777 | skb = rx_queue->rx_skbuff[rx_queue->skb_currx]; |
2777 | 2778 | ||
2778 | dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr, | 2779 | dma_unmap_single(priv->dev, bdp->bufPtr, |
2779 | priv->rx_buffer_size, DMA_FROM_DEVICE); | 2780 | priv->rx_buffer_size, DMA_FROM_DEVICE); |
2780 | 2781 | ||
2781 | if (unlikely(!(bdp->status & RXBD_ERR) && | 2782 | if (unlikely(!(bdp->status & RXBD_ERR) && |
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 8b4de57a5c23..8b27e5ff54c0 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h | |||
@@ -1060,6 +1060,7 @@ struct gfar_private { | |||
1060 | unsigned int total_tx_ring_size; | 1060 | unsigned int total_tx_ring_size; |
1061 | unsigned int total_rx_ring_size; | 1061 | unsigned int total_rx_ring_size; |
1062 | 1062 | ||
1063 | struct device *dev; | ||
1063 | struct net_device *ndev; | 1064 | struct net_device *ndev; |
1064 | struct platform_device *ofdev; | 1065 | struct platform_device *ofdev; |
1065 | enum gfar_errata errata; | 1066 | enum gfar_errata errata; |