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 6CE18C25B10 for ; Mon, 13 May 2024 12:48:16 +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:MIME-Version:Message-ID:In-reply-to: Date:Subject:Cc:To:From:References:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2Ryg9ZsbEkg6UJZbafwJHNaiIp26AH50ZmIbPf7KdIE=; b=D6fWVqxpnqBn4Z gyVqylanKzZzoRq/cJ9ZYvs1gvs0KnoXQwVsmeCSWGAlBzEKq3mRTWpWMtF9ipxpvMCObwF3I80pu HGKDPZZZKlfdLybHdlGuKhk/+ijJCjiP1lFSNBJZRzlPncnbfjM/JASJmUqPhbPuF7pSlJUqJq+OI jy5BmMyfFKoyjeaKojbUXfNaCAp4tTe26TiCP5a+zjQCzziNFM6VssNrdsRO+ecWKEIjkk9u7ez+k 7xApJOUs3MG6dVbn6AByGfm0s8NMR3dLE7wOn5QOneq+rcDEidMck9D6PAIu2gpKWYf/QB3zOYX3Y Thj3QnDLUd0LxHpa28EQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6V64-0000000CsDn-21WL; Mon, 13 May 2024 12:48:04 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6V61-0000000CsCj-1GyS for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2024 12:48:02 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4200ee78f33so15416045e9.3 for ; Mon, 13 May 2024 05:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715604476; x=1716209276; darn=lists.infradead.org; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=fPNX1+WwpMtldcZbMIphrzlav74hQQ8rXHdwhbhRO+4=; b=vHOlu98DdExAzox7oxfUQnjTVFY7vPC9b0e9ve+KDYHkREz8FThI2zzVACK7GwW5Jl AnV0AK2FjR4RlgUYImCly5luVE4XjzJPwZ23wfWwdqgAB2jzW7pTkpDV9P2F0Z7Zh5qa 7Is4DJ846Ydf8yENkFdFZIZSuordY7XSfXMyrGuXE05llgUGs4RwK5vTAKi9jMYpvmCg b9qKeV0MPqvNZd3xpBrxCcE4YVZoEIqQsf/JZw5qBK1RE0JhDy+nrFeXyc3bVRl1a2ie bAeStOdczmMQ+YQsvwhHtC8Gkpxy7ODmf1u/CDXU/GEk2sJII3G2k+PzmRaPQ2PVSpY4 ZQ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715604476; x=1716209276; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fPNX1+WwpMtldcZbMIphrzlav74hQQ8rXHdwhbhRO+4=; b=QeUTts2AfD9LWKEt92VD0NnqL42Ge6HE81LZ1lg8VI0lVJle49kNZaALfMeGlLSdIN a24g+/OlPdnY12JqfprKjaO8VGsD9ukZvNgJGjmov030PTPQLMwdsHfEQI7VAYaWYuy4 7PMpawYWGtLdWcXCQwfK4CgwRP2BWsj/6/M7jgB9z94jjgPg/Mbe4UFlWcMtQfzfe/pa T+SfacE97CmXHSg/pgHA88yLjP3d9aT2fxGGX+nEWi8MJSB85IN9QIxHAFzEFdFM0iFQ lbCTh9kjFIJbYvmD1sN2irm/x3YBfgXFkEVAnsE/4Qrno8IAQWLayCQjaD4bMP3IpfrL Rs7w== X-Forwarded-Encrypted: i=1; AJvYcCXI70WYvAWAfXFby85jFc8wH9MnV3PLqGZAp/Ea64verO53IMXmOQsZxyQxD0XCJLSC2x/EA8lAeuU1yWR4pEDiQATkRBGvABKqxmNJr7u48yOhGf4= X-Gm-Message-State: AOJu0Yz7p/wopFIo0YjhcfbXX043+JeCVATrK+f+S5iJtncu/eojGNBb phamddwcQBcpi8gsvo7NVsED/EV2hChAfest4zJuVS9fbQD4L2X8jdnIAJw/kS0= X-Google-Smtp-Source: AGHT+IEk+Met1qf2o3dGT4F3YeppkeI/2Ixdh7UZ2ZMou78Xn6gzYNBNsB2yR/oj9LHHrEyEco7psg== X-Received: by 2002:adf:f48a:0:b0:34c:6b36:33e5 with SMTP id ffacd0b85a97d-3504aa6a22emr6914680f8f.71.1715604475948; Mon, 13 May 2024 05:47:55 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:5b77:3e5a:a808:339a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b896ab0sm11140161f8f.41.2024.05.13.05.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 05:47:55 -0700 (PDT) References: <20240510090933.19464-1-ddrokosov@salutedevices.com> <20240510090933.19464-2-ddrokosov@salutedevices.com> User-agent: mu4e 1.10.8; emacs 29.2 From: Jerome Brunet To: Dmitry Rokosov Cc: neil.armstrong@linaro.org, jbrunet@baylibre.com, mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, khilman@baylibre.com, martin.blumenstingl@googlemail.com, jian.hu@amlogic.com, kernel@sberdevices.ru, rockosov@gmail.com, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 1/7] clk: meson: introduce 'INIT_ONCE' flag to eliminate init for enabled PLL Date: Mon, 13 May 2024 14:44:06 +0200 In-reply-to: <20240510090933.19464-2-ddrokosov@salutedevices.com> Message-ID: <1jfrulzxms.fsf@starbuckisacylon.baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240513_054801_351773_7AF0B1DF X-CRM114-Status: GOOD ( 27.56 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. > + 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 I agree that currently that carefully reading the code clears that up but it is misleading CLK_MESON_PLL_EN_NOINIT ? > + 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel