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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DFD7C25B10 for ; Mon, 13 May 2024 21:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:CC: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=AM6f9kY226WMMkFo2tTPvUrYzXOZTuwVqB3Ze7w6fOo=; b=X30dWglVdqA2gi JIBngTj9k+mX0HER9ODJQcH+8vydZc3+Wk/RdfUmVwO/zTQT4xeuEGf9i2IJfkWlla8XPl6IEeJHH 3OHapro2/NO5Q045yz0K7tCRTAfkpiavir+6qs1s/Kkv5Y775hVZX9O19dtqb4OKxiON152OuovYT ae9WiUl9umXRD252WN4FIzW06ccgHJIQrGc8IUcNnuLuN7kzmmI7Xy5ZzRnDQagjCvV9Yu5mJtFen voD2eOefLHXkSqABlH44pCcMd2Ojq0hJKIlQKsG7n+Dy3zAhXyovmlMhSqYBNAglDtm21p36BF1eo NNOlk8kHT5TeDOiC17zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6dWD-0000000EILd-0KbV; Mon, 13 May 2024 21:47:37 +0000 Received: from mx2.sberdevices.ru ([45.89.224.132] helo=mx1.sberdevices.ru) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6dW9-0000000EIKl-2WuJ; Mon, 13 May 2024 21:47:35 +0000 Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 591CE12001C; Tue, 14 May 2024 00:47:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 591CE12001C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1715636849; bh=ZM+lhNatKFUHF9a5/vTMQlspJzgvNe8FHwZNKI0g9q0=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:From; b=vSR/QEKByL5EOOHvOy4bWeZ01VVdtBRk4ratwRSJMeGDlEA7q+1H4RIko65+sPvvw 8pgRVvW9Q5IM2cyfTMoM7glWw6OYHmYHXCzizc1xhHmrRhDMo/Ha+WJAEiu84k30js HgWDmc6UaAC9mXZ/RPlq/gZ8xo+M2wUUBPwmZJd9eMfyMJ4IMYZ0+vEW73X2Mpz6dk gWotq29uAjyKzT92Ha++7hStbvYbBoN0E5nCST/lCJZk8/Mr9FnlziwQKoMkUEzVTz u7V6sXnHeMBol2wYHoVf3qwfp3cnW0QY4cjcO3wjUtbdafjckNvnA4XbPVia0wV49v v6l6RDAvU8S+A== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Tue, 14 May 2024 00:47:29 +0300 (MSK) Received: from localhost (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 14 May 2024 00:47:28 +0300 Date: Tue, 14 May 2024 00:47:28 +0300 From: Dmitry Rokosov To: Jerome Brunet CC: , , , , , , , , , , , , , , Subject: Re: [PATCH v2 1/7] clk: meson: introduce 'INIT_ONCE' flag to eliminate init for enabled PLL Message-ID: <20240513214728.g4isbfisifxalqxy@CAB-WSD-L081021> References: <20240510090933.19464-1-ddrokosov@salutedevices.com> <20240510090933.19464-2-ddrokosov@salutedevices.com> <1jfrulzxms.fsf@starbuckisacylon.baylibre.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1jfrulzxms.fsf@starbuckisacylon.baylibre.com> User-Agent: NeoMutt/20220415 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 185198 [May 13 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: ddrokosov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 20 0.3.20 743589a8af6ec90b529f2124c2bbfc3ce1d2f20f, {Track_E25351}, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;salutedevices.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/05/13 16:04:00 #25186646 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240513_144734_082431_EF6364EF X-CRM114-Status: GOOD ( 37.71 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org On Mon, May 13, 2024 at 02:44:06PM +0200, Jerome Brunet wrote: > > On Fri 10 May 2024 at 12:08, Dmitry Rokosov wrote: > > > When dealing with certain PLLs, it is necessary to avoid modifying them > > if they have already been initialized by lower levels. For instance, in > > the A1 SoC Family, the sys_pll is enabled as the parent for the cpuclk, > > and it cannot be disabled during the initialization sequence. Therefore, > > initialization phase must be skipped. > > > > Signed-off-by: Dmitry Rokosov > > --- > > drivers/clk/meson/clk-pll.c | 37 +++++++++++++++++++++---------------- > > drivers/clk/meson/clk-pll.h | 1 + > > 2 files changed, 22 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c > > index 78d17b2415af..47b22a6be2e4 100644 > > --- a/drivers/clk/meson/clk-pll.c > > +++ b/drivers/clk/meson/clk-pll.c > > @@ -289,11 +289,32 @@ static int meson_clk_pll_wait_lock(struct clk_hw *hw) > > return -ETIMEDOUT; > > } > > > > +static int meson_clk_pll_is_enabled(struct clk_hw *hw) > > +{ > > + struct clk_regmap *clk = to_clk_regmap(hw); > > + struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); > > + > > + if (MESON_PARM_APPLICABLE(&pll->rst) && > > + meson_parm_read(clk->map, &pll->rst)) > > + return 0; > > + > > + if (!meson_parm_read(clk->map, &pll->en) || > > + !meson_parm_read(clk->map, &pll->l)) > > + return 0; > > + > > + return 1; > > +} > > + > > static int meson_clk_pll_init(struct clk_hw *hw) > > { > > struct clk_regmap *clk = to_clk_regmap(hw); > > struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); > > > > + /* Do not init already enabled PLL which marked with 'init_once' > > */ > > That is decribing the code, which we can read. So not really helpful > Saying why you do it, like "Keep the clock running from the bootloader > stage and avoid glitching it ..." gives more context about what you are > trying to do. > Yes, I agree with you. "Instead of describing the action, provide the reasoning behind it." I will incorporate your feedback in the upcoming version. > > + if ((pll->flags & CLK_MESON_PLL_INIT_ONCE) && > > I don't like INIT_ONCE. It gives the false impression that > > * The PLL is going to be initialized once in Linux if it has the flag > * Is initialised multiple times otherwise But that's how things happen. For previous clocks on other platforms, we assumed that the PLL could be initialized multiple times: once from the bootloader and once from Linux. We didn't have the ability to disable initialization from the Linux side before, so it meant that multiple initializations were potentially possible by default. > > I agree that currently that carefully reading the code clears that up > but it is misleading > > CLK_MESON_PLL_EN_NOINIT ? > I have been considering this name and its derivatives, such as: CLK_MESON_PLL_SKIP_ENABLED CLK_MESON_PLL_NOINIT_ENABLED CLK_MESON_PLL_INIT_DISABLED_ONLY However, I find all of these names to be quite long and bulky. It reminded me of the WARN_ONCE() function, which ensures that a warning message is only printed once. In my opinion, the name "INIT_ONCE" accurately reflects the situation. Nevertheless, if it is your requirement for me to change the flag name, I am more than willing to do so, it's not a problem. > > + meson_clk_pll_is_enabled(hw)) > > + return 0; > > + > > if (pll->init_count) { > > if (MESON_PARM_APPLICABLE(&pll->rst)) > > meson_parm_write(clk->map, &pll->rst, 1); > > @@ -308,22 +329,6 @@ static int meson_clk_pll_init(struct clk_hw *hw) > > return 0; > > } > > > > -static int meson_clk_pll_is_enabled(struct clk_hw *hw) > > -{ > > - struct clk_regmap *clk = to_clk_regmap(hw); > > - struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); > > - > > - if (MESON_PARM_APPLICABLE(&pll->rst) && > > - meson_parm_read(clk->map, &pll->rst)) > > - return 0; > > - > > - if (!meson_parm_read(clk->map, &pll->en) || > > - !meson_parm_read(clk->map, &pll->l)) > > - return 0; > > - > > - return 1; > > -} > > - > > static int meson_clk_pcie_pll_enable(struct clk_hw *hw) > > { > > int retries = 10; > > diff --git a/drivers/clk/meson/clk-pll.h b/drivers/clk/meson/clk-pll.h > > index a2228c0fdce5..23195ea4eae1 100644 > > --- a/drivers/clk/meson/clk-pll.h > > +++ b/drivers/clk/meson/clk-pll.h > > @@ -28,6 +28,7 @@ struct pll_mult_range { > > } > > > > #define CLK_MESON_PLL_ROUND_CLOSEST BIT(0) > > +#define CLK_MESON_PLL_INIT_ONCE BIT(1) > > > > struct meson_clk_pll_data { > > struct parm en; > > > -- > Jerome -- Thank you, Dmitry _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic