From patchwork Mon Oct 12 16:00:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 35781 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 6B7591009A5 for ; Tue, 13 Oct 2009 03:01:17 +1100 (EST) Received: by ozlabs.org (Postfix) id 2AE81B80C0; Tue, 13 Oct 2009 03:00:38 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from buildserver.ru.mvista.com (unknown [213.79.90.228]) by ozlabs.org (Postfix) with ESMTP id 6EF7DB8082 for ; Tue, 13 Oct 2009 03:00:37 +1100 (EST) Received: from localhost (unknown [10.150.0.9]) by buildserver.ru.mvista.com (Postfix) with ESMTP id 25C5F881D; Mon, 12 Oct 2009 21:00:36 +0500 (SAMST) Date: Mon, 12 Oct 2009 20:00:36 +0400 From: Anton Vorontsov To: David Miller Subject: [PATCH 5/8] gianfar: Move tbase/rbase initialization to gfar_init_mac() Message-ID: <20091012160036.GE2463@oksana.dev.rtsoft.ru> References: <20091012160000.GA32406@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091012160000.GA32406@oksana.dev.rtsoft.ru> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Scott Wood , linuxppc-dev@ozlabs.org, netdev@vger.kernel.org, Andy Fleming X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org 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 --- drivers/net/gianfar.c | 17 ++++++++--------- drivers/net/gianfar.h | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 4dcaaa7..46b0b37 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) { struct txbd8 *txbdp; struct rxbd8 *rxbdp; - dma_addr_t addr = 0; void *vaddr; int i; struct gfar_private *priv = netdev_priv(ndev); struct device *dev = &priv->ofdev->dev; - struct gfar __iomem *regs = priv->regs; /* Allocate memory for the buffer descriptors */ vaddr = dma_alloc_coherent(dev, sizeof(*txbdp) * priv->tx_ring_size + sizeof(*rxbdp) * priv->rx_ring_size, - &addr, GFP_KERNEL); + &priv->tx_bd_dma_base, GFP_KERNEL); if (!vaddr) { if (netif_msg_ifup(priv)) 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; - /* enet DMA only understands physical addresses */ - gfar_write(®s->tbase0, addr); - /* 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; priv->rx_bd_base = vaddr; - gfar_write(®s->rbase0, addr); /* Setup the skbuff rings */ 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 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 */ gfar_write(®s->txic, 0); if (priv->txcoalescing) @@ -1060,7 +1059,7 @@ skip_rx_skbuff: dma_free_coherent(dev, sizeof(*txbdp) * priv->tx_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) diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index 2cd9433..05732fa 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h @@ -726,6 +726,7 @@ struct gfar_private { unsigned long txic; /* Buffer descriptor pointers */ + dma_addr_t tx_bd_dma_base; struct txbd8 *tx_bd_base; /* First tx buffer descriptor */ struct txbd8 *cur_tx; /* Next free ring entry */ struct txbd8 *dirty_tx; /* First buffer in line