From patchwork Tue May 8 08:26:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 10385697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2AD9602C2 for ; Tue, 8 May 2018 08:27:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2E9A28600 for ; Tue, 8 May 2018 08:27:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9780928779; Tue, 8 May 2018 08:27:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07FB728600 for ; Tue, 8 May 2018 08:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754798AbeEHI0t (ORCPT ); Tue, 8 May 2018 04:26:49 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:42634 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754795AbeEHI0q (ORCPT ); Tue, 8 May 2018 04:26:46 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w488QgOj018067; Tue, 8 May 2018 03:26:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1525768002; bh=yUo+9B7ds018eEHZY9Yy0o01G1yn1RhoqYNLpsDzcjI=; h=From:To:CC:Subject:Date; b=O1Uci68iInJvNoMSFegzQrnqIrlmLTC08ke5LOZaHye8XBh1xhw2xzAzFGwWh8VW/ XK5kxEanTgpLcYrNlCj4Xbt4oaQnDC7/XRWeIwpOU5tYOrv0VwtIVe1RcWtgyzrMRE dhO8gnZbhU4z5ivHYgaUdk7perVuD8JGVu+QIpQk= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w488Qgqw008939; Tue, 8 May 2018 03:26:42 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 8 May 2018 03:26:41 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 8 May 2018 03:26:41 -0500 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w488Qd4Q028065; Tue, 8 May 2018 03:26:40 -0500 From: Sekhar Nori To: Grygorii Strashko CC: "David S . Miller" , , Subject: [PATCH net-next] drivers: net: davinci_mdio: prevent sprious timeout Date: Tue, 8 May 2018 13:56:38 +0530 Message-ID: <20180508082638.5707-1-nsekhar@ti.com> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A well timed kernel preemption in the time_after() loop in wait_for_idle() can result in a spurious timeout error to be returned. Fix it by checking for status of hardware before returning timeout error. Signed-off-by: Sekhar Nori --- The issue has not been personally observed by me, but has been reported by users. Sending for next-next given the non-critical nature. There is seems to be no easy way to reproduce this. drivers/net/ethernet/ti/davinci_mdio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index 3c33f4504d8e..4fbd04fd38cf 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -231,10 +231,16 @@ static inline int wait_for_idle(struct davinci_mdio_data *data) while (time_after(timeout, jiffies)) { if (__raw_readl(®s->control) & CONTROL_IDLE) - return 0; + goto out; } - dev_err(data->dev, "timed out waiting for idle\n"); - return -ETIMEDOUT; + + if (!(__raw_readl(®s->control) & CONTROL_IDLE)) { + dev_err(data->dev, "timed out waiting for idle\n"); + return -ETIMEDOUT; + } + +out: + return 0; } static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg)