From patchwork Fri Sep 11 20:25:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 53503 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 4F66222B26 for ; Fri, 11 Sep 2015 20:26:00 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf22735974wic.1 for ; Fri, 11 Sep 2015 13:25:59 -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=SKGucGWFTLA8C6elrrxDSRmVtPrBBvHwcI9fjfGKCpU=; b=FlHM+eU5OB+SAJL/te8Y7QtrGc0ClD/qkt31ywdbyxx4qMkzF4pnzx4xBOBPzWtQ6T ElSRAEx0rvEZeaoWrOjp8GC1+w+DXsN9UwuWlmQUFRR4fhs6exWUtkkFVTwANWb8dcJI zXSaus4OkaMT1fBhLL3DRcwU6swMj5F+QPA8pTpqrKTbhblp9Rjfwh3KG4ljGylOLsIQ wFm0VCmWj7JeD72G+BOt2XF1Yv4VYLqDYI8tvfwt/ZctlgehI+00qe3w9Cf2nrjtgXQs pMdcCf/j5k7HRebHtAIYaG7cCO9/fBmhBBM8SOrCCfZmCcFXfLK6A3GIjojccNA69EE4 0zWg== X-Gm-Message-State: ALoCoQn2uMJO8GJmv9pGh+aSzb6s5F6D/FOhaZmj+j9ZnfJ2fleMN/hm/3Fmdq2uXuJZ6KhQuMtT X-Received: by 10.180.8.135 with SMTP id r7mr30831wia.0.1442003159633; Fri, 11 Sep 2015 13:25:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.39 with SMTP id s7ls149659lae.15.gmail; Fri, 11 Sep 2015 13:25:59 -0700 (PDT) X-Received: by 10.152.21.229 with SMTP id y5mr644137lae.44.1442003159230; Fri, 11 Sep 2015 13:25:59 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id tp6si1259140lbb.97.2015.09.11.13.25.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 13:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagj9 with SMTP id j9so55848552lag.2 for ; Fri, 11 Sep 2015 13:25:58 -0700 (PDT) X-Received: by 10.152.7.210 with SMTP id l18mr634006laa.86.1442003158888; Fri, 11 Sep 2015 13:25:58 -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.59.35 with SMTP id w3csp1819208lbq; Fri, 11 Sep 2015 13:25:57 -0700 (PDT) X-Received: by 10.107.6.73 with SMTP id 70mr6553107iog.158.1442003157759; Fri, 11 Sep 2015 13:25:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si571977igx.15.2015.09.11.13.25.56; Fri, 11 Sep 2015 13:25:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S1753963AbbIKUZz (ORCPT + 29 others); Fri, 11 Sep 2015 16:25:55 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:44028 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753760AbbIKUZx (ORCPT ); Fri, 11 Sep 2015 16:25:53 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 78B045188058 Received: by dusk.luon.net (Postfix, from userid 1000) id 0E041274B5; Fri, 11 Sep 2015 22:25:49 +0200 (CEST) From: Sjoerd Simons To: David Miller , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: stmmac: Use msleep rather then udelay for reset delay Date: Fri, 11 Sep 2015 22:25:48 +0200 Message-Id: <1442003149-10717-1-git-send-email-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.5.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.45 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 --- Changes in v2: - Use DIV_ROUND_UP instead of handcoding the same 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..ebf6abc 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(DIV_ROUND_UP(data->delays[0], 1000)); + gpio_set_value(reset_gpio, active_low ? 0 : 1); - udelay(data->delays[1]); + if (data->delays[1]) + msleep(DIV_ROUND_UP(data->delays[1], 1000)); + gpio_set_value(reset_gpio, active_low ? 1 : 0); - udelay(data->delays[2]); + if (data->delays[2]) + msleep(DIV_ROUND_UP(data->delays[2], 1000)); } } #endif