From patchwork Wed Jun 8 20:42:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 9165661 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 76C27604DB for ; Wed, 8 Jun 2016 20:45:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6834528047 for ; Wed, 8 Jun 2016 20:45:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C8C928294; Wed, 8 Jun 2016 20:45:32 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C488628047 for ; Wed, 8 Jun 2016 20:45:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAkKf-0004v4-Qc; Wed, 08 Jun 2016 20:44:09 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAkKc-0004tc-QT for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2016 20:44:07 +0000 Received: from localhost.localdomain ([95.91.39.67]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0MMnFv-1b669l3gy7-008Yhq; Wed, 08 Jun 2016 22:43:23 +0200 From: Stefan Wahren To: David Miller , Fugang Duan Subject: [PATCH net-next RFT] net: fec: handle small PHY reset durations more precisely Date: Wed, 8 Jun 2016 20:42:46 +0000 Message-Id: <1465418567-2694-1-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 1.7.9.5 X-Provags-ID: V03:K0:qfCrAaHb/jVb5zXkdk+r8XHfWjirugIxg1zjYu2wYiU/66ZOv2w AntQRHi3eNdKaatNM8ZTQ2uGMEdbxdrA/E5zZIjGiv7iB6Lru2JLtA/3hcbcP4hMznBpxpf 6Ku0inl8YvgF1OcK7l14TkwI3A2yZzN2KnuhlwoOexckiz38tnmOAjFox6p3nyrXDfoXWUb 67QLwVTIAiq8fYsIR6BCw== X-UI-Out-Filterresults: notjunk:1; V01:K0:BVRZp0i/f2A=:q2RAGcD65ngoczyfyAhNl9 VNPgo3C/JKNXFkSiqvy6MfOCLLZWvMVNRkpChQOWIVeqCyKZG/RicduFllQp1unXSVVe860MP E2CpoBb4FhVWpvluJXsvOaBbUu06uqw1qAFIphQu4saXthSmJroD+7idVQZr+w248FpqTkaaN 1HZ+vTCLYNtMo1red7TB8DB9M0pbR4xID0f2EsiCFObO8lYgSXa6t/UPL7u+29PgSE8oVSaGK Sbjc7QnlmvfoqrZ+pfDhchPzxOSMx5AnVuCiKv7KRuUqsuWOcQmcGFEMU7PaEsU55/geUUuX5 EUTcWc/mmdAxLNs6qiY+O6CZFVk93R1tPJeuswJcHtDrLFbE+kwZSJ8Yy8DBjiNTEi5dzztKv ZbOvAp6gh2UDbHPFoK8lNGj1j/XMd5ORbwQBtY6TC+wOltJYvEoEKkt5xskewxj3n4LAheqmh PYS1ITStrupZMOhZDUa9r5boAcio9plAGMR9hQ2ldxmaqJ1x7tg3u5uEg+jzHuoIt8+0sUF/z OKHQdTD8lEs6ucRZ0kcU0gHSY7vjQ+lby3lDkFgNy095Uz9fM4xtN8L6MHt26aWEQfkLYQENC krOqZ2d79r97+lhpL8uOFvj9QAe8RrPqMx+yARuaUtoRhyU3maVHDP7r0tW0ueTjft7M8lraM CkXAezB2cKlI4gcPgpZ+5v35GZUBoaef4KwjYVcwtmj9f+8fEJPtxVvt/hDL6nPTvDpU= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160608_134407_195932_EA46D1F6 X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , andrew@lunn.ch, netdev@vger.kernel.org, Troy Kisky , Fabio Estevam , holgerschurig@gmail.com, linux-arm-kernel@lists.infradead.org, Lucas Stach MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Since msleep is based on jiffies the PHY reset could take longer than expected. So use msleep for values greater than 20 msec otherwise usleep_range. Signed-off-by: Stefan Wahren Acked-by: Fugang Duan --- drivers/net/ethernet/freescale/fec_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 3c0255e..49f8055 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3191,7 +3191,12 @@ static void fec_reset_phy(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); return; } - msleep(msec); + + if (msec > 20) + msleep(msec); + else + usleep_range(msec * 1000, msec * 1000 + 1000); + gpio_set_value_cansleep(phy_reset, !active_high); } #else /* CONFIG_OF */