diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-10-12 02:00:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-13 02:54:03 -0400 |
commit | 32c513bca062f6c04b902d09c716fea205671e23 (patch) | |
tree | 1e0bc56d3d0b3c5b8c544c6a355ebbe3b33ae78a /drivers/net/gianfar.c | |
parent | 826aa4a05669a46e435f65db901186e42bb43d8d (diff) |
gianfar: Move tbase/rbase initialization to gfar_init_mac()
For hibernation we want to call gfar_init_mac() without need to
free/allocate_skb_resources sequence, so save the DMA address into a
private struct, and move tbase/rbase initialization to gfar_init_mac().
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r-- | drivers/net/gianfar.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index c8735540b1ec..068f9a2cf42c 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -151,17 +151,15 @@ static int gfar_alloc_skb_resources(struct net_device *ndev) | |||
151 | { | 151 | { |
152 | struct txbd8 *txbdp; | 152 | struct txbd8 *txbdp; |
153 | struct rxbd8 *rxbdp; | 153 | struct rxbd8 *rxbdp; |
154 | dma_addr_t addr = 0; | ||
155 | void *vaddr; | 154 | void *vaddr; |
156 | int i; | 155 | int i; |
157 | struct gfar_private *priv = netdev_priv(ndev); | 156 | struct gfar_private *priv = netdev_priv(ndev); |
158 | struct device *dev = &priv->ofdev->dev; | 157 | struct device *dev = &priv->ofdev->dev; |
159 | struct gfar __iomem *regs = priv->regs; | ||
160 | 158 | ||
161 | /* Allocate memory for the buffer descriptors */ | 159 | /* Allocate memory for the buffer descriptors */ |
162 | vaddr = dma_alloc_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size + | 160 | vaddr = dma_alloc_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size + |
163 | sizeof(*rxbdp) * priv->rx_ring_size, | 161 | sizeof(*rxbdp) * priv->rx_ring_size, |
164 | &addr, GFP_KERNEL); | 162 | &priv->tx_bd_dma_base, GFP_KERNEL); |
165 | if (!vaddr) { | 163 | if (!vaddr) { |
166 | if (netif_msg_ifup(priv)) | 164 | if (netif_msg_ifup(priv)) |
167 | pr_err("%s: Could not allocate buffer descriptors!\n", | 165 | pr_err("%s: Could not allocate buffer descriptors!\n", |
@@ -171,14 +169,9 @@ static int gfar_alloc_skb_resources(struct net_device *ndev) | |||
171 | 169 | ||
172 | priv->tx_bd_base = vaddr; | 170 | priv->tx_bd_base = vaddr; |
173 | 171 | ||
174 | /* enet DMA only understands physical addresses */ | ||
175 | gfar_write(®s->tbase0, addr); | ||
176 | |||
177 | /* Start the rx descriptor ring where the tx ring leaves off */ | 172 | /* Start the rx descriptor ring where the tx ring leaves off */ |
178 | addr = addr + sizeof(*txbdp) * priv->tx_ring_size; | ||
179 | vaddr = vaddr + sizeof(*txbdp) * priv->tx_ring_size; | 173 | vaddr = vaddr + sizeof(*txbdp) * priv->tx_ring_size; |
180 | priv->rx_bd_base = vaddr; | 174 | priv->rx_bd_base = vaddr; |
181 | gfar_write(®s->rbase0, addr); | ||
182 | 175 | ||
183 | /* Setup the skbuff rings */ | 176 | /* Setup the skbuff rings */ |
184 | priv->tx_skbuff = kmalloc(sizeof(*priv->tx_skbuff) * | 177 | priv->tx_skbuff = kmalloc(sizeof(*priv->tx_skbuff) * |
@@ -256,6 +249,12 @@ static void gfar_init_mac(struct net_device *ndev) | |||
256 | u32 tctrl = 0; | 249 | u32 tctrl = 0; |
257 | u32 attrs = 0; | 250 | u32 attrs = 0; |
258 | 251 | ||
252 | /* enet DMA only understands physical addresses */ | ||
253 | gfar_write(®s->tbase0, priv->tx_bd_dma_base); | ||
254 | gfar_write(®s->rbase0, priv->tx_bd_dma_base + | ||
255 | sizeof(*priv->tx_bd_base) * | ||
256 | priv->tx_ring_size); | ||
257 | |||
259 | /* Configure the coalescing support */ | 258 | /* Configure the coalescing support */ |
260 | gfar_write(®s->txic, 0); | 259 | gfar_write(®s->txic, 0); |
261 | if (priv->txcoalescing) | 260 | if (priv->txcoalescing) |
@@ -1060,7 +1059,7 @@ skip_rx_skbuff: | |||
1060 | 1059 | ||
1061 | dma_free_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size + | 1060 | dma_free_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size + |
1062 | sizeof(*rxbdp) * priv->rx_ring_size, | 1061 | sizeof(*rxbdp) * priv->rx_ring_size, |
1063 | priv->tx_bd_base, gfar_read(&priv->regs->tbase0)); | 1062 | priv->tx_bd_base, priv->tx_bd_dma_base); |
1064 | } | 1063 | } |
1065 | 1064 | ||
1066 | void gfar_start(struct net_device *dev) | 1065 | void gfar_start(struct net_device *dev) |