From patchwork Sun Sep 6 15:50:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 53196 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id DCEF622B05 for ; Sun, 6 Sep 2015 15:51:14 +0000 (UTC) Received: by lbcjc2 with SMTP id jc2sf18957703lbc.0 for ; Sun, 06 Sep 2015 08:51:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=pE1juydn9+xYom5ByBd4J1Bpp5G6sf6M/mjncjLfgP0=; b=XtXyFNFu8Rm6mvnq6eErM8kBMPLe/U2nfZpnkpXjpY8LelAfAuSJ+mIL6fwwa4t4jq zcgmmUCHPh8JhOcv3tN9wCO8kIDxIdJfhjHa692q7SoELmCnNM9HW+HQPi5XK8OB2l4w MyULYbx8fflYGHVnx/RACbzt+licjRcXfnwYm2PcBIngaL3bB84dk2A1K9092YjHhCB+ K6SFqu8rqOYDC7PkfI+gVzmeNbtYaYcwQFu6gKwubojKnnN+Ys3epagDrX84SqAvUOHz 4wSwbos+uypXlkCIDlnKwlJzXwwP38/beaXB8bm0MaEDfjLYNSOMW2mYSP5Lhu5NSryC QS4g== X-Gm-Message-State: ALoCoQldnVATfCI3eg1UrhSzZtm2jt8ZRn83RtgV3YqFjbnpgtH1Uokue+89nHzht2wg0dkUP5MS X-Received: by 10.112.48.41 with SMTP id i9mr3720882lbn.23.1441554673878; Sun, 06 Sep 2015 08:51:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.99 with SMTP id p3ls416284laj.57.gmail; Sun, 06 Sep 2015 08:51:13 -0700 (PDT) X-Received: by 10.112.218.5 with SMTP id pc5mr12947064lbc.97.1441554673434; Sun, 06 Sep 2015 08:51:13 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id g4si8097077laa.21.2015.09.06.08.51.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2015 08:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lagj9 with SMTP id j9so39520252lag.2 for ; Sun, 06 Sep 2015 08:51:13 -0700 (PDT) X-Received: by 10.112.168.66 with SMTP id zu2mr2627960lbb.29.1441554673100; Sun, 06 Sep 2015 08:51:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.181.71 with SMTP id du7csp113022lbc; Sun, 6 Sep 2015 08:51:11 -0700 (PDT) X-Received: by 10.68.162.99 with SMTP id xz3mr35216688pbb.134.1441554671755; Sun, 06 Sep 2015 08:51:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si15539759pdb.148.2015.09.06.08.51.10; Sun, 06 Sep 2015 08:51:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbbIFPvH (ORCPT + 4 others); Sun, 6 Sep 2015 11:51:07 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:35565 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbbIFPvF (ORCPT ); Sun, 6 Sep 2015 11:51:05 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 64E4F3C88691 Received: by dusk.luon.net (Postfix, from userid 1000) id C352D21CE0; Sun, 6 Sep 2015 17:50:59 +0200 (CEST) From: Sjoerd Simons To: Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: stmmac: Use msleep rather then udelay for reset delay Date: Sun, 6 Sep 2015 17:50:59 +0200 Message-Id: <1441554659-8419-1-git-send-email-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.5.1 Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sjoerd.simons@collabora.co.uk X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The reset delays used for stmmac are in the order of 10ms to 1 second, which is far too long for udelay usage, so switch to using msleep. Practically this fixes the PHY not being reliably detected in some cases as udelay wouldn't actually delay for long enough to let the phy reliably be reset. Signed-off-by: Sjoerd Simons --- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index b735fa2..17fa588 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -161,11 +161,16 @@ int stmmac_mdio_reset(struct mii_bus *bus) if (!gpio_request(reset_gpio, "mdio-reset")) { gpio_direction_output(reset_gpio, active_low ? 1 : 0); - udelay(data->delays[0]); + if (data->delays[0]) + msleep((data->delays[0] + 999) / 1000); + gpio_set_value(reset_gpio, active_low ? 0 : 1); - udelay(data->delays[1]); + if (data->delays[1]) + msleep((data->delays[1] + 999) / 1000); + gpio_set_value(reset_gpio, active_low ? 1 : 0); - udelay(data->delays[2]); + if (data->delays[2]) + msleep((data->delays[2] + 999) / 1000); } } #endif