[PATCH v4 03/68] clk: Move no reparent case into a separate function
Marek Szyprowski
m.szyprowski at samsung.com
Tue Jun 13 11:15:01 UTC 2023
On 05.05.2023 13:25, Maxime Ripard wrote:
> From: Stephen Boyd <sboyd at kernel.org>
>
> We'll need to turn the code in clk_mux_determine_rate_flags() to deal
> with CLK_SET_RATE_NO_REPARENT into a helper clock drivers will be able
> to use if they don't want to allow reparenting.
>
> Cc: Abel Vesa <abelvesa at kernel.org>
> Cc: Alessandro Zummo <a.zummo at towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni at bootlin.com>
> Cc: Alexandre Torgue <alexandre.torgue at foss.st.com>
> Cc: "Andreas Färber" <afaerber at suse.de>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
> Cc: Baolin Wang <baolin.wang at linux.alibaba.com>
> Cc: Charles Keepax <ckeepax at opensource.cirrus.com>
> Cc: Chen-Yu Tsai <wens at csie.org>
> Cc: Chen-Yu Tsai <wenst at chromium.org>
> Cc: Chunyan Zhang <zhang.lyra at gmail.com>
> Cc: Claudiu Beznea <claudiu.beznea at microchip.com>
> Cc: Daniel Vetter <daniel at ffwll.ch>
> Cc: David Airlie <airlied at gmail.com>
> Cc: David Lechner <david at lechnology.com>
> Cc: Dinh Nguyen <dinguyen at kernel.org>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas at glider.be>
> Cc: Jaroslav Kysela <perex at perex.cz>
> Cc: Jernej Skrabec <jernej.skrabec at gmail.com>
> Cc: Jonathan Hunter <jonathanh at nvidia.com>
> Cc: Kishon Vijay Abraham I <kishon at kernel.org>
> Cc: Liam Girdwood <lgirdwood at gmail.com>
> Cc: Linus Walleij <linus.walleij at linaro.org>
> Cc: Luca Ceresoli <luca.ceresoli at bootlin.com>
> Cc: Manivannan Sadhasivam <mani at kernel.org>
> Cc: Mark Brown <broonie at kernel.org>
> Cc: Markus Schneider-Pargmann <msp at baylibre.com>
> Cc: Max Filippov <jcmvbkbc at gmail.com>
> Cc: Maxime Coquelin <mcoquelin.stm32 at gmail.com>
> Cc: Mikko Perttunen <mperttunen at nvidia.com>
> Cc: Miles Chen <miles.chen at mediatek.com>
> Cc: Nicolas Ferre <nicolas.ferre at microchip.com>
> Cc: Orson Zhai <orsonzhai at gmail.com>
> Cc: Paul Cercueil <paul at crapouillou.net>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Peter De Schrijver <pdeschrijver at nvidia.com>
> Cc: Prashant Gaikwad <pgaikwad at nvidia.com>
> Cc: Richard Fitzgerald <rf at opensource.cirrus.com>
> Cc: Samuel Holland <samuel at sholland.org>
> Cc: Sascha Hauer <s.hauer at pengutronix.de>
> Cc: Sekhar Nori <nsekhar at ti.com>
> Cc: Shawn Guo <shawnguo at kernel.org>
> Cc: Takashi Iwai <tiwai at suse.com>
> Cc: Thierry Reding <thierry.reding at gmail.com>
> Cc: Ulf Hansson <ulf.hansson at linaro.org>
> Cc: Vinod Koul <vkoul at kernel.org>
> Cc: dri-devel at lists.freedesktop.org
> Cc: linux-actions at lists.infradead.org
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-mips at vger.kernel.org
> Cc: linux-phy at lists.infradead.org
> Cc: linux-renesas-soc at vger.kernel.org
> Cc: linux-rtc at vger.kernel.org
> Cc: linux-stm32 at st-md-mailman.stormreply.com
> Cc: linux-sunxi at lists.linux.dev
> Cc: linux-tegra at vger.kernel.org
> Cc: NXP Linux Team <linux-imx at nxp.com>
> Cc: patches at opensource.cirrus.com
> Cc: Pengutronix Kernel Team <kernel at pengutronix.de>
> Signed-off-by: Stephen Boyd <sboyd at kernel.org>
> Signed-off-by: Maxime Ripard <maxime at cerno.tech>
> ---
This patch landed in today's linux-next as commit 1b4e99fda73f ("clk:
Move no reparent case into a separate function"). Unfortunately it
causes serious regression of some of my test boards. Namely Exynos3250
based boards are so slow after it, that my test scripts fail with a
timeout waiting for them to finish booting. I will try to debug this
later in the evening to check what has happened that some clocks got
very low rate.
> drivers/clk/clk.c | 75
> +++++++++++++++++++++++++++++++------------------------
> 1 file changed, 43 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index e495dd7a1eae..f57f821a5e5a 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -594,6 +594,46 @@ clk_core_forward_rate_req(struct clk_core *core,
> req->max_rate = old_req->max_rate;
> }
> +static int
> +clk_core_determine_rate_no_reparent(struct clk_hw *hw,
> + struct clk_rate_request *req)
> +{
> + struct clk_core *core = hw->core;
> + struct clk_core *parent = core->parent;
> + unsigned long best;
> + int ret;
> +
> + if (core->flags & CLK_SET_RATE_PARENT) {
> + struct clk_rate_request parent_req;
> +
> + if (!parent) {
> + req->rate = 0;
> + return 0;
> + }
> +
> + clk_core_forward_rate_req(core, req, parent, &parent_req,
> + req->rate);
> +
> + trace_clk_rate_request_start(&parent_req);
> +
> + ret = clk_core_round_rate_nolock(parent, &parent_req);
> + if (ret)
> + return ret;
> +
> + trace_clk_rate_request_done(&parent_req);
> +
> + best = parent_req.rate;
> + } else if (parent) {
> + best = clk_core_get_rate_nolock(parent);
> + } else {
> + best = clk_core_get_rate_nolock(core);
> + }
> +
> + req->rate = best;
> +
> + return 0;
> +}
> +
> int clk_mux_determine_rate_flags(struct clk_hw *hw,
> struct clk_rate_request *req,
> unsigned long flags)
> @@ -603,35 +643,8 @@ int clk_mux_determine_rate_flags(struct clk_hw *hw,
> unsigned long best = 0;
> /* if NO_REPARENT flag set, pass through to current parent */
> - if (core->flags & CLK_SET_RATE_NO_REPARENT) {
> - parent = core->parent;
> - if (core->flags & CLK_SET_RATE_PARENT) {
> - struct clk_rate_request parent_req;
> -
> - if (!parent) {
> - req->rate = 0;
> - return 0;
> - }
> -
> - clk_core_forward_rate_req(core, req, parent, &parent_req, req->rate);
> -
> - trace_clk_rate_request_start(&parent_req);
> -
> - ret = clk_core_round_rate_nolock(parent, &parent_req);
> - if (ret)
> - return ret;
> -
> - trace_clk_rate_request_done(&parent_req);
> -
> - best = parent_req.rate;
> - } else if (parent) {
> - best = clk_core_get_rate_nolock(parent);
> - } else {
> - best = clk_core_get_rate_nolock(core);
> - }
> -
> - goto out;
> - }
> + if (core->flags & CLK_SET_RATE_NO_REPARENT)
> + return clk_core_determine_rate_no_reparent(hw, req);
> /* find the parent that can provide the fastest rate <= rate */
> num_parents = core->num_parents;
> @@ -670,9 +683,7 @@ int clk_mux_determine_rate_flags(struct clk_hw *hw,
> if (!best_parent)
> return -EINVAL;
> -out:
> - if (best_parent)
> - req->best_parent_hw = best_parent->hw;
> + req->best_parent_hw = best_parent->hw;
> req->best_parent_rate = best;
> req->rate = best;
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
More information about the dri-devel
mailing list