From patchwork Tue Dec 3 13:16:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Schichan X-Patchwork-Id: 3275881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B0A1C0D4A for ; Tue, 3 Dec 2013 13:16:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3CBB201DE for ; Tue, 3 Dec 2013 13:16:52 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9676E201C0 for ; Tue, 3 Dec 2013 13:16:51 +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 1VnpqJ-0003gE-Ey; Tue, 03 Dec 2013 13:16:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VnpqG-0003QB-Vn; Tue, 03 Dec 2013 13:16:44 +0000 Received: from smtp3-g21.free.fr ([2a01:e0c:1:1599::12]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VnpqE-0003PD-2q for linux-arm-kernel@lists.infradead.org; Tue, 03 Dec 2013 13:16:43 +0000 Received: from daria.iliad.local (unknown [213.36.7.13]) by smtp3-g21.free.fr (Postfix) with ESMTP id 97690A63E9; Tue, 3 Dec 2013 14:16:13 +0100 (CET) From: Nicolas Schichan To: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Cooper , "David S. Miller" Subject: [PATCH] net: mvmdio: fix wait_event_timeout() being called with a 1 jiffy timeout. Date: Tue, 3 Dec 2013 14:16:00 +0100 Message-Id: <1386076560-1886-1-git-send-email-nschichan@freebox.fr> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <20131203122346.GD29282@titan.lakedaemon.net> References: <20131203122346.GD29282@titan.lakedaemon.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131203_081642_805098_23EDB084 X-CRM114-Status: GOOD ( 11.39 ) X-Spam-Score: -1.9 (-) Cc: Leigh Brown , Florian Fainelli , Nicolas Schichan , Sebastian Hesselbarth 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.2 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 If a timer interrupt kicks right after the wait_event_timeout() call, we may endup a reporting timeout before the timeout really occured. Signed-off-by: Nicolas Schichan --- drivers/net/ethernet/marvell/mvmdio.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index 7354960..2814bbc 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -76,9 +76,19 @@ static int orion_mdio_wait_ready(struct mii_bus *bus) { struct orion_mdio_dev *dev = bus->priv; unsigned long timeout = usecs_to_jiffies(MVMDIO_SMI_TIMEOUT); - unsigned long end = jiffies + timeout; + unsigned long end; int timedout = 0; + /* + * make sure that we wait at least more than one + * jiffy. wait_event_timeout() with a timeout parameter of 1 + * jiffy may return before the SMI access is done if a timer + * interrupt kicks immediately after. + */ + if (timeout < 2) + timeout = 2; + end = jiffies + timeout; + while (1) { if (orion_mdio_smi_is_done(dev)) return 0;