From patchwork Thu Jun 6 06:55:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 249293 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B43C12C02C3 for ; Thu, 6 Jun 2013 16:57:35 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UkU8G-00076k-6M; Thu, 06 Jun 2013 06:57:12 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UkU8D-0007Ca-8H; Thu, 06 Jun 2013 06:57:09 +0000 Received: from co1ehsobe005.messaging.microsoft.com ([216.32.180.188] helo=co1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UkU8A-0007Bq-Jk for linux-arm-kernel@lists.infradead.org; Thu, 06 Jun 2013 06:57:07 +0000 Received: from mail207-co1-R.bigfish.com (10.243.78.227) by CO1EHSOBE015.bigfish.com (10.243.66.78) with Microsoft SMTP Server id 14.1.225.23; Thu, 6 Jun 2013 06:56:38 +0000 Received: from mail207-co1 (localhost [127.0.0.1]) by mail207-co1-R.bigfish.com (Postfix) with ESMTP id 982AF3008F8; Thu, 6 Jun 2013 06:56:38 +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 mail207-co1 (localhost.localdomain [127.0.0.1]) by mail207-co1 (MessageSwitch) id 1370501732693947_14187; Thu, 6 Jun 2013 06:55:32 +0000 (UTC) Received: from CO1EHSMHS020.bigfish.com (unknown [10.243.78.231]) by mail207-co1.bigfish.com (Postfix) with ESMTP id 86FE3DC00CB; Thu, 6 Jun 2013 06:55:31 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS020.bigfish.com (10.243.66.30) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 6 Jun 2013 06:55:31 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.328.11; Thu, 6 Jun 2013 06:56:46 +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 r566tRcN002355; Wed, 5 Jun 2013 23:55:28 -0700 From: Peter Chen To: Subject: [PATCH 1/1] ARM: imx: clk-pllv3: change wait method for PLL lock Date: Thu, 6 Jun 2013 14:55:26 +0800 Message-ID: <1370501726-7421-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-20130606_025706_814909_6AED5EC2 X-CRM114-Status: GOOD ( 13.15 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.32.180.188 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org For tickless system, the jiffies may be updated long time (>20ms). At high loading system, the current waiting method will cause waiting timeout, and cause a kernel dump at below case. After timeout = jiffies + msecs_to_jiffies(10), the timer interrupt occurs, it 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 --- arch/arm/mach-imx/clk-pllv3.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/clk-pllv3.c b/arch/arm/mach-imx/clk-pllv3.c index 36aac94..eefc6c2 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 @@ -50,7 +51,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); @@ -62,9 +63,11 @@ 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)) + while (!(readl_relaxed(pll->base) & BM_PLL_LOCK)) { + udelay(100); + if (--count == 0) return -ETIMEDOUT; + } return 0; }