From patchwork Fri Nov 2 17:39:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin Kumar X-Patchwork-Id: 196718 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 758072C00C8 for ; Sat, 3 Nov 2012 05:19:31 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 639DF4A7EA; Fri, 2 Nov 2012 19:18:26 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZTG9pDz6MTuE; Fri, 2 Nov 2012 19:18:26 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 352D34AEDD; Fri, 2 Nov 2012 19:17:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F0124AED2 for ; Fri, 2 Nov 2012 19:16:51 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p7xgCKaa24k7 for ; Fri, 2 Nov 2012 19:16:49 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from eu1sys200aog118.obsmtp.com (eu1sys200aog118.obsmtp.com [207.126.144.145]) by theia.denx.de (Postfix) with ESMTPS id AB5634AEBD for ; Fri, 2 Nov 2012 19:16:41 +0100 (CET) Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKUJQOCYtOm7ZfdUOtIeiIkGPMXKh8yO+c@postini.com; Fri, 02 Nov 2012 18:16:44 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 7931719C; Fri, 2 Nov 2012 17:36:34 +0000 (GMT) Received: from Webmail-ap.st.com (eapex1hubcas2.st.com [10.80.176.10]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id AB171107D; Fri, 2 Nov 2012 17:44:47 +0000 (GMT) Received: from localhost (10.251.136.62) by Webmail-ap.st.com (10.80.176.7) with Microsoft SMTP Server (TLS) id 8.3.245.1; Sat, 3 Nov 2012 01:44:46 +0800 From: Vipin Kumar To: Date: Fri, 2 Nov 2012 23:09:59 +0530 Message-ID: X-Mailer: git-send-email 1.7.10.rc2.10.gb47606 In-Reply-To: <1c8cd3ce05a1064788a96bb4b49f9b82d9caf736.1351877124.git.vipin.kumar@st.com> References: <1c8cd3ce05a1064788a96bb4b49f9b82d9caf736.1351877124.git.vipin.kumar@st.com> MIME-Version: 1.0 Cc: Shiraz Hashim , sr@denx.de, spear-devel@list.st.com Subject: [U-Boot] [Drivers PATCH 14/19] net/macb: workaround for transmission hang issue X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Shiraz Hashim It is observed on SPEAr320S RMII#1 interface that on transmitting packets the MAC dma hangs randomly and constantly showing busy tx-go state. It comes out if this situation only when Transmission is disabled and enabled again. Since it happens randomly and u-boot doesn't require high performance we disable TE and re-enable it on each transmission. We also change number of transmit descriptor to 1 as we would not require more than it, further it would not alter GMAC notion of transmit descriptor start queue as it always point to same descriptor. Signed-off-by: Shiraz Hashim Tested-by: Bo Shen --- drivers/net/macb.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index ac25b52..17bad33 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -55,7 +55,7 @@ #define CONFIG_SYS_MACB_RX_BUFFER_SIZE 4096 #define CONFIG_SYS_MACB_RX_RING_SIZE (CONFIG_SYS_MACB_RX_BUFFER_SIZE / 128) -#define CONFIG_SYS_MACB_TX_RING_SIZE 16 +#define CONFIG_SYS_MACB_TX_RING_SIZE 1 #define CONFIG_SYS_MACB_TX_TIMEOUT 1000 #define CONFIG_SYS_MACB_AUTONEG_TIMEOUT 5000000 @@ -226,7 +226,13 @@ static int macb_send(struct eth_device *netdev, void *packet, int length) macb->tx_ring[tx_head].ctrl = ctrl; macb->tx_ring[tx_head].addr = paddr; barrier(); - macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE) | MACB_BIT(TSTART)); + /* + * Due to issues on SPEAr320 RMII, disable TE first so that + * controller can come out if it is hanged during transmission + */ + macb_writel(macb, NCR, macb_readl(macb, NCR) & ~MACB_BIT(TE)); + macb_writel(macb, NCR, macb_readl(macb, NCR) | + MACB_BIT(TE) | MACB_BIT(TSTART)); /* * I guess this is necessary because the networking core may @@ -444,6 +450,31 @@ static int macb_phy_init(struct macb_device *macb) } } +static void macb_reset_hw(struct macb_device *bp) +{ + /* Make sure we have the write buffer for ourselves */ + barrier(); + /* + * Disable RX and TX (XXX: Should we halt the transmission + * more gracefully?) and we should not close the mdio port + */ + macb_writel(bp, NCR, 0); + + /* Clear the stats registers (XXX: Update stats first?) */ + macb_writel(bp, NCR, MACB_BIT(CLRSTAT)); + + /* keep the mdio port , otherwise other eth will not work */ + macb_writel(bp, NCR, MACB_BIT(MPE)); + + /* Clear all status flags */ + macb_writel(bp, TSR, ~0UL); + macb_writel(bp, RSR, ~0UL); + + /* Disable all interrupts */ + macb_writel(bp, IDR, ~0UL); + macb_readl(bp, ISR); +} + static int macb_init(struct eth_device *netdev, bd_t *bd) { struct macb_device *macb = to_macb(netdev); @@ -520,8 +551,7 @@ static void macb_halt(struct eth_device *netdev) tsr = macb_readl(macb, TSR); } while (tsr & MACB_BIT(TGO)); - /* Disable TX and RX, and clear statistics */ - macb_writel(macb, NCR, MACB_BIT(CLRSTAT)); + macb_reset_hw(macb); } static int macb_write_hwaddr(struct eth_device *dev)