From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB893C433DF for ; Fri, 26 Jun 2020 21:05:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A19E206B7 for ; Fri, 26 Jun 2020 21:05:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MpzQiw8e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A19E206B7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UzN0cxy9NaX+6TRqtzsrIz64l99kAqULyzzY+ksryYU=; b=MpzQiw8etu3/z1heF/+LO/C8J RyLpD5VxCmMd7S/ziL8Yma47WOqUHAIVhsPLhBs5IlHGWCCZGhgwFQGSAhnbo/BncOp74UyTUJHcd 2ebrfG9gWncZAIBzXBr/5ERBEou9yWuwMAoRnSiyM3y47Hw1GfQ9UZCg5zgeigsMzTW8GHxXA5a8C qpUdTo3ULtpvdsMWNBLR2N6yK/SNHIFM8nMpjKJNFexYwh0rNzsuiENsp6o8YpjX0+CBnk11zp2F5 USc+hDxtgUrrKf8JW3LRPhoXlDwxo+FQXMkTlhzs6178nOr/UWotdOMwDzB3II7hlVL5tp+lLh3+M kRXmdtXWg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jovW0-0005b4-38; Fri, 26 Jun 2020 21:04:04 +0000 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jovVw-0005a4-Qt for linux-arm-kernel@lists.infradead.org; Fri, 26 Jun 2020 21:04:02 +0000 X-Originating-IP: 86.202.110.81 Received: from localhost (lfbn-lyo-1-15-81.w86-202.abo.wanadoo.fr [86.202.110.81]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 4CC30FF804; Fri, 26 Jun 2020 21:03:57 +0000 (UTC) Date: Fri, 26 Jun 2020 23:03:57 +0200 From: Alexandre Belloni To: Claudiu Beznea Subject: Re: [PATCH 2/2] clk: at91: main: do not continue if oscillators already prepared Message-ID: <20200626210357.GX131826@piout.net> References: <1593079768-9349-1-git-send-email-claudiu.beznea@microchip.com> <1593079768-9349-2-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1593079768-9349-2-git-send-email-claudiu.beznea@microchip.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mturquette@linaro.org, bbrezillon@kernel.org, sboyd@kernel.org, mturquette@baylibre.com, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 25/06/2020 13:09:28+0300, Claudiu Beznea wrote: > Return in clk_main_osc_prepare()/clk_main_rc_osc_prepare() if > oscillators are already enabled. > > Fixes: 27cb1c2083373 ("clk: at91: rework main clk implementation") > Fixes: 1bdf02326b71e ("clk: at91: make use of syscon/regmap internally") Is this really a fix? What is the observed issue? > Signed-off-by: Claudiu Beznea > --- > drivers/clk/at91/clk-main.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c > index 37c22667e831..46b4d2131989 100644 > --- a/drivers/clk/at91/clk-main.c > +++ b/drivers/clk/at91/clk-main.c > @@ -74,13 +74,11 @@ static int clk_main_osc_prepare(struct clk_hw *hw) > regmap_read(regmap, AT91_CKGR_MOR, &tmp); > tmp &= ~MOR_KEY_MASK; > > - if (tmp & AT91_PMC_OSCBYPASS) > + if (tmp & (AT91_PMC_OSCBYPASS | AT91_PMC_MOSCEN)) > return 0; While this seems like a good optimization, it is also not correct. Having AT91_PMC_MOSCEN set doesn't mean that the clock is ready, you need to at least check MOSCS once. > > - if (!(tmp & AT91_PMC_MOSCEN)) { > - tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY; > - regmap_write(regmap, AT91_CKGR_MOR, tmp); > - } > + tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY; > + regmap_write(regmap, AT91_CKGR_MOR, tmp); > > while (!clk_main_osc_ready(regmap)) > cpu_relax(); > @@ -186,10 +184,12 @@ static int clk_main_rc_osc_prepare(struct clk_hw *hw) > > regmap_read(regmap, AT91_CKGR_MOR, &mor); > > - if (!(mor & AT91_PMC_MOSCRCEN)) > - regmap_update_bits(regmap, AT91_CKGR_MOR, > - MOR_KEY_MASK | AT91_PMC_MOSCRCEN, > - AT91_PMC_MOSCRCEN | AT91_PMC_KEY); > + if (mor & AT91_PMC_MOSCRCEN) > + return 0; > + > + regmap_update_bits(regmap, AT91_CKGR_MOR, > + MOR_KEY_MASK | AT91_PMC_MOSCRCEN, > + AT91_PMC_MOSCRCEN | AT91_PMC_KEY); > > while (!clk_main_rc_osc_ready(regmap)) > cpu_relax(); > -- > 2.7.4 > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel