Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753387AbdLSWZ3 (ORCPT ); Tue, 19 Dec 2017 17:25:29 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:42850 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753324AbdLSWZ1 (ORCPT ); Tue, 19 Dec 2017 17:25:27 -0500 Date: Tue, 19 Dec 2017 23:25:15 +0100 From: Alexandre Belloni To: Romain Izard Cc: Boris Brezillon , Michael Turquette , Stephen Boyd , Nicolas Ferre , Ludovic Desroches , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v6 1/3] clk: at91: pmc: Wait for clocks when resuming Message-ID: <20171219222515.GS15162@piout.net> References: <20171211165535.5126-1-romain.izard.pro@gmail.com> <20171211165535.5126-2-romain.izard.pro@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171211165535.5126-2-romain.izard.pro@gmail.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1900 Lines: 67 On 11/12/2017 at 17:55:33 +0100, Romain Izard wrote: > Wait for the syncronization of all clocks when resuming, not only the > UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG() > when interrupts are masked, which is the case in here. > > Signed-off-by: Romain Izard > Acked-by: Ludovic Desroches > Acked-by: Nicolas Ferre Acked-by: Alexandre Belloni > --- > drivers/clk/at91/pmc.c | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > > diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c > index 775af473fe11..5c2b26de303e 100644 > --- a/drivers/clk/at91/pmc.c > +++ b/drivers/clk/at91/pmc.c > @@ -107,10 +107,20 @@ static int pmc_suspend(void) > return 0; > } > > +static bool pmc_ready(unsigned int mask) > +{ > + unsigned int status; > + > + regmap_read(pmcreg, AT91_PMC_SR, &status); > + > + return ((status & mask) == mask) ? 1 : 0; > +} > + > static void pmc_resume(void) > { > - int i, ret = 0; > + int i; > u32 tmp; > + u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA; > > regmap_read(pmcreg, AT91_PMC_MCKR, &tmp); > if (pmc_cache.mckr != tmp) > @@ -134,13 +144,11 @@ static void pmc_resume(void) > AT91_PMC_PCR_CMD); > } > > - if (pmc_cache.uckr & AT91_PMC_UPLLEN) { > - ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp, > - !(tmp & AT91_PMC_LOCKU), > - 10, 5000); > - if (ret) > - pr_crit("USB PLL didn't lock when resuming\n"); > - } > + if (pmc_cache.uckr & AT91_PMC_UPLLEN) > + mask |= AT91_PMC_LOCKU; > + > + while (!pmc_ready(mask)) > + cpu_relax(); > } > > static struct syscore_ops pmc_syscore_ops = { > -- > 2.14.1 > -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com