From patchwork Fri Aug 22 19:40:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 382335 X-Patchwork-Delegate: sbabic@denx.de 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 1D42D140082 for ; Sat, 23 Aug 2014 05:41:21 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D03F8A73FA; Fri, 22 Aug 2014 21:41:19 +0200 (CEST) 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 P579-27ivSAo; Fri, 22 Aug 2014 21:41:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C13DA7421; Fri, 22 Aug 2014 21:41:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2E22DA743D for ; Fri, 22 Aug 2014 21:41:10 +0200 (CEST) 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 Ey06vlgpRZJX for ; Fri, 22 Aug 2014 21:41:05 +0200 (CEST) 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 mail-yk0-f179.google.com (mail-yk0-f179.google.com [209.85.160.179]) by theia.denx.de (Postfix) with ESMTPS id 314DAA7414 for ; Fri, 22 Aug 2014 21:41:02 +0200 (CEST) Received: by mail-yk0-f179.google.com with SMTP id 142so8826448ykq.24 for ; Fri, 22 Aug 2014 12:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mX0Vnd51otEcv4FD625F5JQVdWM6j5ZUvd2n6dR3U+E=; b=H61E6hMa9uem6OEG4L2qkCnnV2qHFDb+4HLd/mahJCugLl48YhjMh+uNiepkgKxB6A rnWCzutNfInRsQUoPFRNJ2p/w0R39HxVdY++7igRdUNQBmDh+/yPtgh3roYqGByssYII lcrLYR4YDnXXE8qOBda1mgmz8ZuOR66mPpy0oMjkYa/b+oqk+lj9+TrsCT9/AkIjCNud V8X0bvLQlr+q5QcEOgdVMFW6L/xN0MBC6L6vKK3rXydd+ABSdaOtfZIXe9fqCUJoqIzu sWuWk0Z7B7k+Lay0Dqoo8/BzFHxSqjhnIgZzhjJsWchzGz7vtbgWeLvTs/ngGYdXHPiU 9M3g== X-Received: by 10.236.231.178 with SMTP id l48mr3895212yhq.143.1408736461205; Fri, 22 Aug 2014 12:41:01 -0700 (PDT) Received: from localhost.localdomain ([189.101.179.48]) by mx.google.com with ESMTPSA id v50sm222816yhv.22.2014.08.22.12.40.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Aug 2014 12:41:00 -0700 (PDT) From: Fabio Estevam To: joe.hershberger@gmail.com Date: Fri, 22 Aug 2014 16:40:39 -0300 Message-Id: <1408736439-3780-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408736439-3780-1-git-send-email-festevam@gmail.com> References: <1408736439-3780-1-git-send-email-festevam@gmail.com> Cc: marex@denx.de, Fabio Estevam , otavio@ossystems.com.br, u-boot@lists.denx.de, sr@denx.de Subject: [U-Boot] [PATCH v5 2/2] net: fec_mxc: Poll FEC_TBD_READY after polling TDAR 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Fabio Estevam When testing the FEC driver on a mx6solox we noticed that the TDAR bit gets always cleared prior then the READY bit is cleared in the last BD, which causes FEC packets reception to always fail. As explained by Ye Li: "The TDAR bit is cleared when the descriptors are all out from TX ring, but on mx6solox we noticed that the READY bit is still not cleared right after TDAR. These are two distinct signals, and in IC simulation, we found that TDAR always gets cleared prior than the READY bit of last BD becomes cleared. In mx6solox, we use a later version of FEC IP. It looks like that this intrinsic behaviour of TDAR bit has changed in this newer FEC version." Fix this by polling the READY bit of BD after the TDAR polling, which covers the mx6solox case and does not harm the other SoCs. No performance drop has been noticed with this patch applied when testing TFTP transfers on several boards of different i.mx SoCs. Signed-off-by: Fabio Estevam --- Changes since v4: - Improve wording in the commit log. drivers/net/fec_mxc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 56178d4..4bfd625 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -719,13 +719,22 @@ static int fec_send(struct eth_device *dev, void *packet, int length) break; } - if (!timeout) + if (!timeout) { ret = -EINVAL; + goto out; + } - invalidate_dcache_range(addr, addr + size); - if (readw(&fec->tbd_base[fec->tbd_index].status) & FEC_TBD_READY) + timeout = FEC_XFER_TIMEOUT; + while (--timeout) { + invalidate_dcache_range(addr, addr + size); + if (!(readw(&fec->tbd_base[fec->tbd_index].status) & FEC_TBD_READY)) + break; + } + + if (!timeout) ret = -EINVAL; +out: debug("fec_send: status 0x%x index %d ret %i\n", readw(&fec->tbd_base[fec->tbd_index].status), fec->tbd_index, ret);