From patchwork Sat Oct 19 16:23:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leigh Brown X-Patchwork-Id: 3072281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 56DCC9F288 for ; Sat, 19 Oct 2013 16:25:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B1012053C for ; Sat, 19 Oct 2013 16:25:20 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57297201E7 for ; Sat, 19 Oct 2013 16:25:19 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VXZKk-000861-4Y; Sat, 19 Oct 2013 16:24:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VXZKf-0005tU-8a; Sat, 19 Oct 2013 16:24:53 +0000 Received: from doppler.thel33t.co.uk ([193.110.88.198]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VXZKT-0005r4-AZ for linux-arm-kernel@lists.infradead.org; Sat, 19 Oct 2013 16:24:42 +0000 Received: from dish.dyn.solinno.co.uk. (82-68-130-54.dsl.in-addr.zen.co.uk [82.68.130.54]) by doppler.thel33t.co.uk (Postfix) with ESMTPSA id 07AED840B5; Sat, 19 Oct 2013 17:28:30 +0100 (BST) From: Leigh Brown To: linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 1/4] net: mvmdio: make orion_mdio_wait_ready consistent Date: Sat, 19 Oct 2013 17:23:51 +0100 Message-Id: <3acbec7a5077d1375777e26cd808b787eb677fb3.1382199042.git.leigh@solinno.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131019_122441_511491_257D065A X-CRM114-Status: GOOD ( 12.83 ) X-Spam-Score: -1.9 (-) Cc: Thomas Petazzoni , netdev@vger.kernel.org, Leigh Brown X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Amend orion_mdio_wait_ready so that the same timeout is used when polling or using wait_event_timeout. Set the timeout to 10ms. Generate the same log message at timeout when polling or using wait_event_timeout. Signed-off-by: Leigh Brown --- drivers/net/ethernet/marvell/mvmdio.c | 41 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index e2f6626..11e6415 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -44,6 +44,13 @@ #define MVMDIO_ERR_INT_SMI_DONE 0x00000010 #define MVMDIO_ERR_INT_MASK 0x0080 +/* + * Testing on a Dreamplug showed that the SMI interface took an average of + * 3.2ms to respond, with a maximum time of 4.9ms. + */ +#define MVMDIO_SMI_TIMEOUT 10000 /* 10000us = 10ms */ +#define MVMDIO_SMI_POLL_INTERVAL 10 + struct orion_mdio_dev { struct mutex lock; void __iomem *regs; @@ -70,32 +77,28 @@ static int orion_mdio_wait_ready(struct mii_bus *bus) struct orion_mdio_dev *dev = bus->priv; int count; - if (dev->err_interrupt <= 0) { - count = 0; - while (1) { + if (dev->err_interrupt <= 0) + for (count = MVMDIO_SMI_TIMEOUT / MVMDIO_SMI_POLL_INTERVAL; + count > 0; + --count) { if (orion_mdio_smi_is_done(dev)) - break; - - if (count > 100) { - dev_err(bus->parent, - "Timeout: SMI busy for too long\n"); - return -ETIMEDOUT; - } + return 0; - udelay(10); - count++; + udelay(MVMDIO_SMI_POLL_INTERVAL); } - } else { - if (!orion_mdio_smi_is_done(dev)) { + else { + if (!orion_mdio_smi_is_done(dev)) wait_event_timeout(dev->smi_busy_wait, orion_mdio_smi_is_done(dev), - msecs_to_jiffies(100)); - if (!orion_mdio_smi_is_done(dev)) - return -ETIMEDOUT; - } + usecs_to_jiffies(MVMDIO_SMI_TIMEOUT)); + + if (orion_mdio_smi_is_done(dev)) + return 0; } - return 0; + dev_err(bus->parent, + "Timeout: SMI busy for too long\n"); + return -ETIMEDOUT; } static int orion_mdio_read(struct mii_bus *bus, int mii_id,