Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbcDUDwz (ORCPT ); Wed, 20 Apr 2016 23:52:55 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34350 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751586AbcDUDwx (ORCPT ); Wed, 20 Apr 2016 23:52:53 -0400 Date: Thu, 21 Apr 2016 11:45:20 +0800 From: Dong Aisheng To: Stefan Agner Cc: shawnguo@kernel.org, kernel@pengutronix.de, mturquette@baylibre.com, sboyd@codeaurora.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de Subject: Re: [PATCH 1/2] clk: imx: do not sleep if IRQ's are still disabled Message-ID: <20160421034520.GA19965@shlinux2.ap.freescale.net> References: <1454107764-19876-1-git-send-email-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1454107764-19876-1-git-send-email-stefan@agner.ch> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1832 Lines: 57 On Fri, Jan 29, 2016 at 02:49:23PM -0800, Stefan Agner wrote: > If a clock gets enabled early during boot time, it can lead to a PLL > startup. The wait_lock function makes sure that the PLL is really > stareted up before it gets used. However, the function sleeps which > leads to scheduling and an error: > bad: scheduling from the idle thread! > ... > > Use udelay in case IRQ's are still disabled. > > Signed-off-by: Stefan Agner > --- > drivers/clk/imx/clk-pllv3.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c > index c05c43d..b5ff561 100644 > --- a/drivers/clk/imx/clk-pllv3.c > +++ b/drivers/clk/imx/clk-pllv3.c > @@ -63,7 +63,10 @@ static int clk_pllv3_wait_lock(struct clk_pllv3 *pll) > break; > if (time_after(jiffies, timeout)) > break; > - usleep_range(50, 500); > + if (unlikely(irqs_disabled())) This causes a bit confusion that clk_pllv3_prepare is sleepable. But this line indicates it's possible to be called in irq context. Although it's only happened during kernel boot phase where irq is still not enabled. It seems schedule_debug() somehow did not catch it during early boot phase. Maybe schedule guys can help explain. My question is if it's really worthy to introduce this confusion to fix the issue since the delay is minor? Furthermore, shouldn't it be udelay(500)? Shawn, What's your idea? Regards Dong Aisheng > + udelay(50); > + else > + usleep_range(50, 500); > } while (1); > > return readl_relaxed(pll->base) & BM_PLL_LOCK ? 0 : -ETIMEDOUT; > -- > 2.7.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-clk" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html