From patchwork Fri Jun 7 08:19:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 2684941 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 58185DFB78 for ; Fri, 7 Jun 2013 08:20:54 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ukru6-0007Yb-IC; Fri, 07 Jun 2013 08:20:11 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ukrtk-00057h-Ok; Fri, 07 Jun 2013 08:19:48 +0000 Received: from mail-db8lp0187.outbound.messaging.microsoft.com ([213.199.154.187] helo=db8outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ukrtd-00056Q-6S for linux-arm-kernel@lists.infradead.org; Fri, 07 Jun 2013 08:19:45 +0000 Received: from mail13-db8-R.bigfish.com (10.174.8.233) by DB8EHSOBE019.bigfish.com (10.174.4.82) with Microsoft SMTP Server id 14.1.225.23; Fri, 7 Jun 2013 08:19:17 +0000 Received: from mail13-db8 (localhost [127.0.0.1]) by mail13-db8-R.bigfish.com (Postfix) with ESMTP id 1B1D64802AB; Fri, 7 Jun 2013 08:19:17 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ah1fc6hzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1155h) Received: from mail13-db8 (localhost.localdomain [127.0.0.1]) by mail13-db8 (MessageSwitch) id 1370593154944693_562; Fri, 7 Jun 2013 08:19:14 +0000 (UTC) Received: from DB8EHSMHS011.bigfish.com (unknown [10.174.8.226]) by mail13-db8.bigfish.com (Postfix) with ESMTP id E40EF1A003F; Fri, 7 Jun 2013 08:19:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB8EHSMHS011.bigfish.com (10.174.4.21) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 7 Jun 2013 08:19:14 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.328.11; Fri, 7 Jun 2013 08:20:31 +0000 Received: from localhost.localdomain (nchen-desktop.ap.freescale.net [10.192.242.40]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r578J7bw009044; Fri, 7 Jun 2013 01:19:09 -0700 From: Peter Chen To: Subject: [PATCH v2 1/1] ARM: imx: clk-pllv3: change wait method for PLL lock Date: Fri, 7 Jun 2013 16:19:06 +0800 Message-ID: <1370593146-14025-1-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130607_041941_796246_DB99EE43 X-CRM114-Status: GOOD ( 14.49 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.199.154.187 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux@arm.linux.org.uk, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, u.kleine-koenig@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For some unknown reasons, the jiffies will be updated more than one tick at every short time. Eg, at this code: After timeout = jiffies + msecs_to_jiffies(10), the interrupt occurs, and the softirq updates jiffies (eg, + 2 jiffies), then return back from interrupt, the time between above operations are tiny, the PLL is still not locked, but the timeout condition is satisfied. Signed-off-by: Peter Chen --- Changes for v2: - According to Russell King's suggestion, change code for more reasonable for timeout condition. - Change commit log. arch/arm/mach-imx/clk-pllv3.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-imx/clk-pllv3.c b/arch/arm/mach-imx/clk-pllv3.c index d09bc3d..52e54df 100644 --- a/arch/arm/mach-imx/clk-pllv3.c +++ b/arch/arm/mach-imx/clk-pllv3.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "clk.h" #define PLL_NUM_OFFSET 0x10 @@ -48,7 +49,7 @@ struct clk_pllv3 { static int clk_pllv3_prepare(struct clk_hw *hw) { struct clk_pllv3 *pll = to_clk_pllv3(hw); - unsigned long timeout = jiffies + msecs_to_jiffies(10); + int count = 100; u32 val; val = readl_relaxed(pll->base); @@ -60,9 +61,14 @@ static int clk_pllv3_prepare(struct clk_hw *hw) writel_relaxed(val, pll->base); /* Wait for PLL to lock */ - while (!(readl_relaxed(pll->base) & BM_PLL_LOCK)) - if (time_after(jiffies, timeout)) - return -ETIMEDOUT; + do { + if (readl_relaxed(pll->base) & BM_PLL_LOCK) + break; + udelay(100); + } while (count--); + + if (count == 0 && !(readl_relaxed(pll->base) & BM_PLL_LOCK)) + return -ETIMEDOUT; return 0; }