Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2268819ybj; Mon, 23 Sep 2019 00:19:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoolAVvtBL0AT0K8XmNmazhd3iy7qlMCzwHz+egemikiezcXpa78Pf92pjyMff+E10izfS X-Received: by 2002:a50:9402:: with SMTP id p2mr35295094eda.111.1569223185599; Mon, 23 Sep 2019 00:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569223185; cv=none; d=google.com; s=arc-20160816; b=MdQwp4ZcEbmYjNa0g3XWOg6lwMzX3RQmIOXG4YTE/l+Ggbea1coHcKY7b8Ar35yEiK pzVettO5C1FM81binjgDK8M0sJfVLX2yGVHc22OKbpoQFg1pM8hHUGjWsGD7LiL4U3eq RzyppId+DBVGOt7iayGgkzCtmTHh655e/o4rAyC8VT5YlhteUMDjpJ9tM4gRzpMl6mZY zp1oyuvszyi2Q+9O+Aj6L5MiWilf7gazK8TDyo7kzphzZxyZJDTl9yqSIZs1oIPLRBpC qCLeJVfRuLi00YCDvaRucgRlzQ6n+niqlbfPOuvngD4Qvj193iHIhubgqtPODnZb+HuJ 1dVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:user-agent:subject:from :to:cc:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=LQJqQhuzG1LUv2a9JfIZef8qnj7UVhdxg1o/Suj85mw=; b=ZpXE2YHjsJcYK3PIpjGTPvMT1QkLkAH/HXAbI7XrGKGgjJUj/6P+ff7AtKg/ohPiCa actVV/F7veH47BHPeFBAaQvzL2nW9B6hDl5bBOPsgvU2LULQoftYQLUUEQZlqgEV3MO0 S8H6Anel+2utfbH+aqKA8rvJ+L8b9+uaEIGC3nM3g7ZjPFi3tX+cB/A9mu9yhNfwkOJD nUveYVJQXZNt4ViXfY+PAhdiHtzHlotgv43AbzVVQZ1Iy5fI+ncoKxsJwnteOVc4s3Es 9G1IRrzt7bCpUdk5WKcQL4s6sm6nNJDpWbYtL+CfUBShNtrBeHmow92eyVWRHyAUbIK/ OfBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0JoVOOxQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si7053518edf.34.2019.09.23.00.19.21; Mon, 23 Sep 2019 00:19:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0JoVOOxQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405164AbfITQwp (ORCPT + 99 others); Fri, 20 Sep 2019 12:52:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:57804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404658AbfITQwo (ORCPT ); Fri, 20 Sep 2019 12:52:44 -0400 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C8BB207FC; Fri, 20 Sep 2019 16:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568998363; bh=TYstjFpPpmJlXXPM8BgcwsN3SWwWCF707s2P3uizfwk=; h=In-Reply-To:References:Cc:To:From:Subject:Date:From; b=0JoVOOxQBmIIvROvdiQqjgNG0IVfCMPOzHRIqpFM4J+X8aI3tOc6/GqDoGvuAD7b+ W1N1tvawHZdnGOKDoCELxkcxaAbcB5W7P2pDeIVG0L0cx9EZm934l+NS0DiT84+T48 yTDO8/XrcVZmt9fc2wBxlbAaT1M2AOWZq2xDww8g= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <2551a729-5379-e039-4d5a-a83fa877fb14@baylibre.com> References: <20190919093627.21245-1-narmstrong@baylibre.com> <20190919093809.21364-1-narmstrong@baylibre.com> <1j1rwce8yf.fsf@starbuckisacylon.baylibre.com> <20190919170610.541D620644@mail.kernel.org> <2551a729-5379-e039-4d5a-a83fa877fb14@baylibre.com> Cc: linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org To: Jerome Brunet , Neil Armstrong From: Stephen Boyd Subject: Re: [PATCH 3/3] clk: meson: clk-pll: always enable a critical PLL when setting the rate User-Agent: alot/0.8.1 Date: Fri, 20 Sep 2019 09:52:42 -0700 Message-Id: <20190920165243.2C8BB207FC@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Neil Armstrong (2019-09-20 01:06:58) > Hi Stephen, >=20 > On 19/09/2019 19:06, Stephen Boyd wrote: > > Quoting Jerome Brunet (2019-09-19 06:01:28) > >> On Thu 19 Sep 2019 at 11:38, Neil Armstrong = wrote: > >> > >>> Make sure we always enable a PLL on a set_rate() when the PLL is > >>> flagged as critical. > >>> > >>> This fixes the case when the Amlogic G12A SYS_PLL gets disabled by the > >>> PSCI firmware when resuming from suspend-to-memory, in the case > >>> where the CPU was not clocked by the SYS_PLL, but by the fixed PLL > >>> fixed divisors. > >>> In this particular case, when changing the PLL rate, CCF doesn't hand= le > >>> the fact the PLL could have been disabled in the meantime and set_rat= e() > >>> only changes the rate and never enables it again. > >>> > >>> Fixes: d6e81845b7d9 ("clk: meson: clk-pll: check if the clock is alre= ady enabled') > >>> Signed-off-by: Neil Armstrong > >>> --- > >>> drivers/clk/meson/clk-pll.c | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c > >>> index ddb1e5634739..8c5adccb7959 100644 > >>> --- a/drivers/clk/meson/clk-pll.c > >>> +++ b/drivers/clk/meson/clk-pll.c > >>> @@ -379,7 +379,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *= hw, unsigned long rate, > >>> } > >>> =20 > >>> /* If the pll is stopped, bail out now */ > >>> - if (!enabled) > >>> + if (!(hw->init->flags & CLK_IS_CRITICAL) && !enabled) > >> > >> This is surely a work around to the issue at hand but: > >> > >> * Enabling the clock, critical or not, should not be done but the > >> set_rate() callback. This is not the purpose of this callback. > >> > >> * Enabling the clock in such way does not walk the tree. So, if there = is > >> ever another PSCI Fw which disable we would get into the same issue > >> again. IOW, This is not specific to the PLL driver so it should not ha= ve > >> to deal with this. > >=20 > > Exactly. > >=20 > >> > >> Since this clock can change out of CCF maybe it should be marked with > >> CLK_GET_RATE_NOCACHE ? > >=20 > > Yes, or figure out a way to make the clk state match what PSCI leaves it > > in on resume from suspend. > >=20 > >=20 > >> > >> When CCF hits a clock with CLK_GET_RATE_NOCACHE while walking the tree, > >> in addition to to calling get_rate(), CCF could also call is_enabled() > >> if the clock has CLK_IS_CRITICAL and possibly .enable() ? > >=20 > > This logic should go under a new flag. The CLK_GET_RATE_NOCACHE flag > > specifically means get rate shouldn't be a cached operation. It doesn't > > relate to the enable state. I hope that you can implement some sort of > > resume hook that synchronizes the state though so that you don't need to > > rely on clk_set_rate() or clk_get_rate() to trigger a sync. > >=20 >=20 > It's exactly the goal of [1] where I resync a clock tree after a resume. Ok. I haven't looked at that series yet. We can move this discussion there if you like. >=20 > But I don't check the enable state, would you mean that: > if core->ops->enable && core->enable_count > 0 && !clk_core_is_enabled(co= re) > core->ops->enable(core->hw) >=20 > along the parent/rate resync ? >=20 > Isn't that dangerous ? >=20 Why is it dangerous? If the clk state is lost across suspend/resume we need to restore the state of the clk somehow. One way would be to have the clk driver tell the framework that this clk is now off and to drop the enable counts for any consumers. Then consumers will need to call clk_enable() again to turn the clk back on in the consumer resume callback. Or we can try to be smarter/nicer and restore the clk state to what the consumer is expecting across suspend/resume. I haven't thought about what is better or worse. On the one hand, device drivers already handle some things not being saved/restored during system low power modes. But on the other hand I don't know what the policy is for external resources that a device uses, such as clks or regulators or pinctrl muxing, etc.