mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 18:53:52 +08:00
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>
This commit is contained in:
parent
826aa4a056
commit
32c513bca0
@ -151,17 +151,15 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
|
|||||||
{
|
{
|
||||||
struct txbd8 *txbdp;
|
struct txbd8 *txbdp;
|
||||||
struct rxbd8 *rxbdp;
|
struct rxbd8 *rxbdp;
|
||||||
dma_addr_t addr = 0;
|
|
||||||
void *vaddr;
|
void *vaddr;
|
||||||
int i;
|
int i;
|
||||||
struct gfar_private *priv = netdev_priv(ndev);
|
struct gfar_private *priv = netdev_priv(ndev);
|
||||||
struct device *dev = &priv->ofdev->dev;
|
struct device *dev = &priv->ofdev->dev;
|
||||||
struct gfar __iomem *regs = priv->regs;
|
|
||||||
|
|
||||||
/* Allocate memory for the buffer descriptors */
|
/* Allocate memory for the buffer descriptors */
|
||||||
vaddr = dma_alloc_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size +
|
vaddr = dma_alloc_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size +
|
||||||
sizeof(*rxbdp) * priv->rx_ring_size,
|
sizeof(*rxbdp) * priv->rx_ring_size,
|
||||||
&addr, GFP_KERNEL);
|
&priv->tx_bd_dma_base, GFP_KERNEL);
|
||||||
if (!vaddr) {
|
if (!vaddr) {
|
||||||
if (netif_msg_ifup(priv))
|
if (netif_msg_ifup(priv))
|
||||||
pr_err("%s: Could not allocate buffer descriptors!\n",
|
pr_err("%s: Could not allocate buffer descriptors!\n",
|
||||||
@ -171,14 +169,9 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
|
|||||||
|
|
||||||
priv->tx_bd_base = vaddr;
|
priv->tx_bd_base = vaddr;
|
||||||
|
|
||||||
/* enet DMA only understands physical addresses */
|
|
||||||
gfar_write(®s->tbase0, addr);
|
|
||||||
|
|
||||||
/* Start the rx descriptor ring where the tx ring leaves off */
|
/* Start the rx descriptor ring where the tx ring leaves off */
|
||||||
addr = addr + sizeof(*txbdp) * priv->tx_ring_size;
|
|
||||||
vaddr = vaddr + sizeof(*txbdp) * priv->tx_ring_size;
|
vaddr = vaddr + sizeof(*txbdp) * priv->tx_ring_size;
|
||||||
priv->rx_bd_base = vaddr;
|
priv->rx_bd_base = vaddr;
|
||||||
gfar_write(®s->rbase0, addr);
|
|
||||||
|
|
||||||
/* Setup the skbuff rings */
|
/* Setup the skbuff rings */
|
||||||
priv->tx_skbuff = kmalloc(sizeof(*priv->tx_skbuff) *
|
priv->tx_skbuff = kmalloc(sizeof(*priv->tx_skbuff) *
|
||||||
@ -256,6 +249,12 @@ static void gfar_init_mac(struct net_device *ndev)
|
|||||||
u32 tctrl = 0;
|
u32 tctrl = 0;
|
||||||
u32 attrs = 0;
|
u32 attrs = 0;
|
||||||
|
|
||||||
|
/* enet DMA only understands physical addresses */
|
||||||
|
gfar_write(®s->tbase0, priv->tx_bd_dma_base);
|
||||||
|
gfar_write(®s->rbase0, priv->tx_bd_dma_base +
|
||||||
|
sizeof(*priv->tx_bd_base) *
|
||||||
|
priv->tx_ring_size);
|
||||||
|
|
||||||
/* Configure the coalescing support */
|
/* Configure the coalescing support */
|
||||||
gfar_write(®s->txic, 0);
|
gfar_write(®s->txic, 0);
|
||||||
if (priv->txcoalescing)
|
if (priv->txcoalescing)
|
||||||
@ -1060,7 +1059,7 @@ skip_rx_skbuff:
|
|||||||
|
|
||||||
dma_free_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size +
|
dma_free_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size +
|
||||||
sizeof(*rxbdp) * priv->rx_ring_size,
|
sizeof(*rxbdp) * priv->rx_ring_size,
|
||||||
priv->tx_bd_base, gfar_read(&priv->regs->tbase0));
|
priv->tx_bd_base, priv->tx_bd_dma_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfar_start(struct net_device *dev)
|
void gfar_start(struct net_device *dev)
|
||||||
|
@ -726,6 +726,7 @@ struct gfar_private {
|
|||||||
unsigned long txic;
|
unsigned long txic;
|
||||||
|
|
||||||
/* Buffer descriptor pointers */
|
/* Buffer descriptor pointers */
|
||||||
|
dma_addr_t tx_bd_dma_base;
|
||||||
struct txbd8 *tx_bd_base; /* First tx buffer descriptor */
|
struct txbd8 *tx_bd_base; /* First tx buffer descriptor */
|
||||||
struct txbd8 *cur_tx; /* Next free ring entry */
|
struct txbd8 *cur_tx; /* Next free ring entry */
|
||||||
struct txbd8 *dirty_tx; /* First buffer in line
|
struct txbd8 *dirty_tx; /* First buffer in line
|
||||||
|
Loading…
Reference in New Issue
Block a user