From patchwork Wed May 9 11:00:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 135249 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5485989lji; Wed, 9 May 2018 04:00:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrqVapg5/y71gshd5mv6tnugnA34VDIGqwUqi1p/XS56UzsgUoeX5yYBwOBhZvgLEL7V+ga X-Received: by 2002:a63:18c:: with SMTP id 134-v6mr21691717pgb.138.1525863640224; Wed, 09 May 2018 04:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525863640; cv=none; d=google.com; s=arc-20160816; b=ScMmCWa4zm15Ch/liVL0I9nnUQGEgxIGUBJFZ4ML4Uop1C+FzMxhgYcOYCMmlUsSR5 iST2bsw+3SaxcGjSdjUwXLKyKykxZoNf6YmLSOx3doviPvWikU4xtQEmOTHNs1AL/Z5P oPP/KeYNUcB4YsjiMdaNfhhFoy3tqi1LwF8cwFiEa6t7U2rInoRqmNxC+zSHLnN2P6j0 hjYuuJurHUMUddWSsT6bhvOTAPXMlxaO/yOrlvtN+e0WNL53iE7mKR1ddlQXtycrXkry uOdxfCCnAQUVNyOtO606kFPiD05Pspr7VSI8pfSkVG5Srf/5MgagQWb08ahpgvtom24B 9jgA== 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=dp7NyDZxizAl2NYUnkq74XwzaftCYZvm/1JBgOmNOrE=; b=lN8w5Wj9fwF+91MHHjWrUJ/3be7MR80i6cfipiDbQFlQiGVKz+JU6tFDaSjp7XhjF5 CNkov6Ej7K9nis+pHQ54YQ0Oo308SVmk/BZrVqnAtb6IebLAxUBd7Loi940RDihw4mUU EcVmQuK1k3NR3zQ1i7InigHQEm2SwceqVMGXrGnQ8+gRkTSQbZW3hf+UHMcsBi7x9hq7 4BQfi1YU3DnLblMsAg867rUDcu+JSj4jkaT5G+PUA4/dhegDT6Xhy53RDwGObohkUS4c S34ZPVNGopIeDBv2+e/HqFh2WCpld5dqKgMJ8duKSl2rgSPHHF2fUrsNAQeFxRpa3mz+ qWuw== 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=BUIKdXiW; 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 l3si25975729pfi.179.2018.05.09.04.00.39; Wed, 09 May 2018 04:00:40 -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=BUIKdXiW; 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 S1753339AbeEILAi (ORCPT + 5 others); Wed, 9 May 2018 07:00:38 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:61673 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750798AbeEILAh (ORCPT ); Wed, 9 May 2018 07:00:37 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w49B0RmR022721; Wed, 9 May 2018 06:00:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1525863627; bh=wpn7wvu7hlWDKiNRjFftrzI6Exq1gpTiMYK1owlKD/E=; h=From:To:CC:Subject:Date; b=BUIKdXiW6KU8C87vjPIgu0PWubhaQDxPQ/I2mH7TZ4Vbf6SBcmhMN6Ld9PBs64gib uWb4iF3TcspXCufWiFzVnI7ASaCg5mn/04HlhORC3Bd3DfpOS5keQgFYPQfzOlUq5W hfPf/Lt7KPYBHucNpGfXe8VBJQKZIOMGs3EDm++E= 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 w49B0R9C031554; Wed, 9 May 2018 06:00:27 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) 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; Wed, 9 May 2018 06:00:27 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE100.ent.ti.com (10.64.6.21) 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 06:00:27 -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 w49B0OZV004098; Wed, 9 May 2018 06:00:25 -0500 From: Sekhar Nori To: "David S . Miller" CC: Grygorii Strashko , , , Andrew Lunn , Sekhar Nori Subject: [PATCH v2 net-next] drivers: net: davinci_mdio: prevent spurious timeout Date: Wed, 9 May 2018 16:30:24 +0530 Message-ID: <20180509110024.1772-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. Signed-off-by: Sekhar Nori --- v2: use readl_poll_timeout() per suggestion 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, 9 insertions(+), 6 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: Andrew Lunn diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index 3c33f4504d8e..d073432a5dbe 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,16 @@ 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; + 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; } - dev_err(data->dev, "timed out waiting for idle\n"); - return -ETIMEDOUT; + + return 0; } static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg)