From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbcEYV6F (ORCPT ); Wed, 25 May 2016 17:58:05 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:33135 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750732AbcEYV6D (ORCPT ); Wed, 25 May 2016 17:58:03 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Wed, 25 May 2016 14:54:07 -0700 From: Stefan Agner To: Thomas Gleixner Cc: Dong Aisheng , Shawn Guo , Lucas Stach , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, mingo@redhat.com, kernel@pengutronix.de, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/2] clk: imx: do not sleep if IRQ's are still disabled In-Reply-To: References: <1454107764-19876-1-git-send-email-stefan@agner.ch> <20160421034520.GA19965@shlinux2.ap.freescale.net> <20160426012341.GB8870@tiger> <1461663072.7839.17.camel@pengutronix.de> <20160427015835.GE30692@tiger> Message-ID: User-Agent: Roundcube Webmail/1.1.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016-04-27 03:15, Thomas Gleixner wrote: > On Wed, 27 Apr 2016, Dong Aisheng wrote: >> Why Stefan's patch works (checking irqs_disabled()) is because during kernel >> time init, the irq is still not enabled. It fixes the issue indirectly. >> See: >> asmlinkage __visible void __init start_kernel(void) >> { >> /* >> * Set up the scheduler prior starting any interrupts (such as the >> * timer interrupt). Full topology setup happens at smp_init() >> * time - but meanwhile we still have a functioning scheduler. >> */ >> sched_init(); >> ............. >> time_init(); >> .............. >> WARN(!irqs_disabled(), "Interrupts were enabled early\n"); >> early_boot_irqs_disabled = false; >> local_irq_enable(); >> } >> >> The issue can only happen when PLL enable causes a schedule during >> imx_clock_init(). > > Calling a function which might sleep _BEFORE_ kernel_init() is wrong. Don't > try to work around such an issue by doing magic irq_disabled() checks and busy > loops. Fix the call site and be done with it. What do you mean exactly by fix the call site? The patch I proposed (https://lkml.org/lkml/2016/1/29/695) fixes the call site... But I see Dong's argument here, irqs_disabled is the wrong way to figure out whether we are in kernel_init. What is the right approach to distinguish whether we are allowed to sleep? -- Stefan