Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752297AbdIVMHI (ORCPT ); Fri, 22 Sep 2017 08:07:08 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:10799 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752039AbdIVMHE (ORCPT ); Fri, 22 Sep 2017 08:07:04 -0400 X-IronPort-AV: E=Sophos;i="5.42,427,1500966000"; d="scan'208";a="7272402" Date: Fri, 22 Sep 2017 14:05:32 +0200 From: Ludovic Desroches To: Romain Izard CC: Nicolas Ferre , Alexandre Belloni , Boris Brezillon , Michael Turquette , Stephen Boyd , Ludovic Desroches , Wenyou Yang , Josh Wu , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Alan Stern , , , , , , , Subject: Re: [PATCH v2 1/9] clk: at91: pmc: Wait for clocks when resuming Message-ID: <20170922120532.jddabnd57yt3iowe@rfolt0960.corp.atmel.com> Mail-Followup-To: Romain Izard , Nicolas Ferre , Alexandre Belloni , Boris Brezillon , Michael Turquette , Stephen Boyd , Wenyou Yang , Josh Wu , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Alan Stern , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pwm@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20170915140411.31716-1-romain.izard.pro@gmail.com> <20170915140411.31716-2-romain.izard.pro@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170915140411.31716-2-romain.izard.pro@gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1793 Lines: 66 On Fri, Sep 15, 2017 at 04:04:03PM +0200, 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 I faced the same issue because of the use of regmap_read_poll_timeout when timekeeping is not ready. Ludovic > --- > 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.11.0 >