aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <r.herring@freescale.com>2010-02-05 03:56:20 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-10 16:05:42 -0500
commit633e7533cec78b99d806248e832fc83e689d2453 (patch)
treece20891b9038d35d21687957491383ed9e167ce8
parent67de792420be2daa1c6fec07ec8552af9ea0bde3 (diff)
fec: fix uninitialized rx buffer usage
The fec driver was enabling receive buffer descriptor without allocating the buffers. Make sure the buffer descriptors are initialized to not start receiving packets. Open also calls fec_restart after the rx buffers are allocated. With the code in fec_restart, it zeroes out the buffer descriptors that have just been setup. Signed-off-by: Rob Herring <r.herring@freescale.com> Signed-off-by: Amit Kucheria <amit.kucheria@canonical.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/fec.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 16a1d58419d9..9a8743daa3e5 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1658,6 +1658,7 @@ static int fec_enet_init(struct net_device *dev, int index)
1658{ 1658{
1659 struct fec_enet_private *fep = netdev_priv(dev); 1659 struct fec_enet_private *fep = netdev_priv(dev);
1660 struct bufdesc *cbd_base; 1660 struct bufdesc *cbd_base;
1661 struct bufdesc *bdp;
1661 int i; 1662 int i;
1662 1663
1663 /* Allocate memory for buffer descriptors. */ 1664 /* Allocate memory for buffer descriptors. */
@@ -1710,6 +1711,34 @@ static int fec_enet_init(struct net_device *dev, int index)
1710 /* Set MII speed to 2.5 MHz */ 1711 /* Set MII speed to 2.5 MHz */
1711 fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999) 1712 fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
1712 / 2500000) / 2) & 0x3F) << 1; 1713 / 2500000) / 2) & 0x3F) << 1;
1714
1715 /* Initialize the receive buffer descriptors. */
1716 bdp = fep->rx_bd_base;
1717 for (i = 0; i < RX_RING_SIZE; i++) {
1718
1719 /* Initialize the BD for every fragment in the page. */
1720 bdp->cbd_sc = 0;
1721 bdp++;
1722 }
1723
1724 /* Set the last buffer to wrap */
1725 bdp--;
1726 bdp->cbd_sc |= BD_SC_WRAP;
1727
1728 /* ...and the same for transmit */
1729 bdp = fep->tx_bd_base;
1730 for (i = 0; i < TX_RING_SIZE; i++) {
1731
1732 /* Initialize the BD for every fragment in the page. */
1733 bdp->cbd_sc = 0;
1734 bdp->cbd_bufaddr = 0;
1735 bdp++;
1736 }
1737
1738 /* Set the last buffer to wrap */
1739 bdp--;
1740 bdp->cbd_sc |= BD_SC_WRAP;
1741
1713 fec_restart(dev, 0); 1742 fec_restart(dev, 0);
1714 1743
1715 /* Queue up command to detect the PHY and initialize the 1744 /* Queue up command to detect the PHY and initialize the
@@ -1730,7 +1759,6 @@ static void
1730fec_restart(struct net_device *dev, int duplex) 1759fec_restart(struct net_device *dev, int duplex)
1731{ 1760{
1732 struct fec_enet_private *fep = netdev_priv(dev); 1761 struct fec_enet_private *fep = netdev_priv(dev);
1733 struct bufdesc *bdp;
1734 int i; 1762 int i;
1735 1763
1736 /* Whack a reset. We should wait for this. */ 1764 /* Whack a reset. We should wait for this. */
@@ -1768,33 +1796,6 @@ fec_restart(struct net_device *dev, int duplex)
1768 } 1796 }
1769 } 1797 }
1770 1798
1771 /* Initialize the receive buffer descriptors. */
1772 bdp = fep->rx_bd_base;
1773 for (i = 0; i < RX_RING_SIZE; i++) {
1774
1775 /* Initialize the BD for every fragment in the page. */
1776 bdp->cbd_sc = BD_ENET_RX_EMPTY;
1777 bdp++;
1778 }
1779
1780 /* Set the last buffer to wrap */
1781 bdp--;
1782 bdp->cbd_sc |= BD_SC_WRAP;
1783
1784 /* ...and the same for transmit */
1785 bdp = fep->tx_bd_base;
1786 for (i = 0; i < TX_RING_SIZE; i++) {
1787
1788 /* Initialize the BD for every fragment in the page. */
1789 bdp->cbd_sc = 0;
1790 bdp->cbd_bufaddr = 0;
1791 bdp++;
1792 }
1793
1794 /* Set the last buffer to wrap */
1795 bdp--;
1796 bdp->cbd_sc |= BD_SC_WRAP;
1797
1798 /* Enable MII mode */ 1799 /* Enable MII mode */
1799 if (duplex) { 1800 if (duplex) {
1800 /* MII enable / FD enable */ 1801 /* MII enable / FD enable */