From patchwork Wed May 9 15:45:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 135298 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5796541lji; Wed, 9 May 2018 08:45:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr10u6gxxi3xcRUnQQZIBtWNVRob3dRQN0SqKT5jHOdfmmIDCozTsRgB089BB1l3zuACx6W X-Received: by 2002:a63:87c6:: with SMTP id i189-v6mr35357526pge.2.1525880731396; Wed, 09 May 2018 08:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525880731; cv=none; d=google.com; s=arc-20160816; b=Kk2oGZ7ep+w0Js0geBnCWmf4SBz2IRXlfLqU7GmcekF+k1KIPgRuWWhF5mgT9TXHBh O4WX3ADgQjNikkqj7UmmVUJtU5a0Xj9epP+cdZXcbxuEzr3L6oM7lPUgqIdGjWEZbaDN zaiR1wKZsD2SFl6FelF8mn8523fC90px1NtaQ8fiFLd84185bWe8r9C+OHPV0KzxDgGz hnhAvUvdZdgLvIdDk2xE942SlJjfL78wijdlDl37skU3/ZwTw7azmH+tOB8LkyPtfP2q Ju1RenCk8gNjCUsMoAJfbGp/1IE3HQmHIXZQGiNuo1MaZBnbrxmdZT6sI5632jVPqdNh As4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=Adk1KdIU3aGj32vCyTVfUfcKPoI3HRN02OM6b0fEHuU=; b=mLDxPqMYD6jwPgharXy6FZB10QzWEouWaGLNGsQqkGMja+NLo0GTB/zbH5cVTheCLA S0io+81SiXyr++YbsBIgLXH9YB54SmO/kon3mtWYaMI9uLG+biVPK1SHRoW2jb9YuNHn EFMXpJXAna9jSpRmkMtrFv4YGIJMu4n94TRTTIBh7y0goJaYYULBD1nHxekkxSS6eSBm NJ49R0tShS9WBcCbAhcgIkSFB6Ll6P9D6LvtOkUBOXS5x6Ci3jV51cBZLG1d0hWMWY1X /RFunUG34I2aChQZUYcvacAnRXAEcKmKdiQDBw8AUzs3FTQ7TJPabM7c8zl3ZapcrqOF IfGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=EK9xGM0Y; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5-v6si15388778pln.562.2018.05.09.08.45.31; Wed, 09 May 2018 08:45:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=EK9xGM0Y; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935406AbeEIPp3 (ORCPT + 5 others); Wed, 9 May 2018 11:45:29 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:22606 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935362AbeEIPp3 (ORCPT ); Wed, 9 May 2018 11:45:29 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w49FjIiV024755; Wed, 9 May 2018 10:45:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1525880718; bh=ZMqYqXnsf9LVG2tHXAv3LzhXdBYQl/nBWQ95COmUaAw=; h=From:To:CC:Subject:Date; b=EK9xGM0YaRQtCqLOy/WC423vPUOoDlUiylOMN6h5ol+hW4/qaA5UohFprdQU9HNxx z2/zAX1xLWGhD+lLrjZ/1UejAXpSyZpQhHtNiDlJGGuPkqYP/R6o2cQf2/XgOEPf7i hOHZENnY9ufUsgNbUlW8sYlw3pegYrLR9GTZ6reI= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w49FjIeX006045; Wed, 9 May 2018 10:45:18 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 9 May 2018 10:45:18 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 9 May 2018 10:45:18 -0500 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w49FjFGW028039; Wed, 9 May 2018 10:45:16 -0500 From: Sekhar Nori To: "David S . Miller" CC: Grygorii Strashko , , , Andrew Lunn , Sekhar Nori Subject: [PATCH v3 next-next] drivers: net: davinci_mdio: prevent spurious timeout Date: Wed, 9 May 2018 21:15:15 +0530 Message-ID: <20180509154515.5968-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 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 using readl_poll_timeout() which takes care of this issue. Reviewed-by: Andrew Lunn Signed-off-by: Sekhar Nori --- v3: simplify return path based on comment from Andrew 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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Grygorii Strashko diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index 3c33f4504d8e..98a1c97fb95e 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -227,14 +228,14 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data) static inline int wait_for_idle(struct davinci_mdio_data *data) { struct davinci_mdio_regs __iomem *regs = data->regs; - unsigned long timeout = jiffies + msecs_to_jiffies(MDIO_TIMEOUT); + u32 val, ret; - while (time_after(timeout, jiffies)) { - if (__raw_readl(®s->control) & CONTROL_IDLE) - return 0; - } - dev_err(data->dev, "timed out waiting for idle\n"); - return -ETIMEDOUT; + ret = readl_poll_timeout(®s->control, val, val & CONTROL_IDLE, + 0, MDIO_TIMEOUT * 1000); + if (ret) + dev_err(data->dev, "timed out waiting for idle\n"); + + return ret; } static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg)