From: Maxime Ripard <maxime@cerno.tech>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org, "Maxime Ripard" <maxime@cerno.tech>,
"Abel Vesa" <abelvesa@kernel.org>,
"Alessandro Zummo" <a.zummo@towertech.it>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Andreas Färber" <afaerber@suse.de>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Charles Keepax" <ckeepax@opensource.cirrus.com>,
"Chen-Yu Tsai" <wens@csie.org>,
"Chen-Yu Tsai" <wenst@chromium.org>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Claudiu Beznea" <claudiu.beznea@microchip.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"David Airlie" <airlied@gmail.com>,
"David Lechner" <david@lechnology.com>,
"Dinh Nguyen" <dinguyen@kernel.org>,
"Fabio Estevam" <festevam@gmail.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Jaroslav Kysela" <perex@perex.cz>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Luca Ceresoli" <luca.ceresoli@bootlin.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Mark Brown" <broonie@kernel.org>,
"Markus Schneider-Pargmann" <msp@baylibre.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Mikko Perttunen" <mperttunen@nvidia.com>,
"Miles Chen" <miles.chen@mediatek.com>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Paul Cercueil" <paul@crapouillou.net>,
"Peng Fan" <peng.fan@nxp.com>,
"Peter De Schrijver" <pdeschrijver@nvidia.com>,
"Prashant Gaikwad" <pgaikwad@nvidia.com>,
"Richard Fitzgerald" <rf@opensource.cirrus.com>,
"Samuel Holland" <samuel@sholland.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Sekhar Nori" <nsekhar@ti.com>, "Shawn Guo" <shawnguo@kernel.org>,
"Takashi Iwai" <tiwai@suse.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Ulf Hansson" <ulf.hansson@linaro.org>,
"Vinod Koul" <vkoul@kernel.org>,
dri-devel@lists.freedesktop.org,
linux-actions@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org,
linux-rtc@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org,
"NXP Linux Team" <linux-imx@nxp.com>,
patches@opensource.cirrus.com,
"Pengutronix Kernel Team" <kernel@pengutronix.de>
Subject: [PATCH v4 03/68] clk: Move no reparent case into a separate function
Date: Fri, 05 May 2023 13:25:05 +0200 [thread overview]
Message-ID: <20221018-clk-range-checks-fixes-v4-3-971d5077e7d2@cerno.tech> (raw)
In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech>
From: Stephen Boyd <sboyd@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@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: "Andreas Färber" <afaerber@suse.de>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Chen-Yu Tsai <wenst@chromium.org>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@gmail.com>
Cc: David Lechner <david@lechnology.com>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Kishon Vijay Abraham I <kishon@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Markus Schneider-Pargmann <msp@baylibre.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
Cc: Miles Chen <miles.chen@mediatek.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Orson Zhai <orsonzhai@gmail.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Prashant Gaikwad <pgaikwad@nvidia.com>
Cc: Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-actions@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mips@vger.kernel.org
Cc: linux-phy@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-sunxi@lists.linux.dev
Cc: linux-tegra@vger.kernel.org
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: patches@opensource.cirrus.com
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
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;
--
2.40.0
next prev parent reply other threads:[~2023-05-05 11:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 11:25 [PATCH v4 00/68] clk: Make determine_rate mandatory for muxes Maxime Ripard
2023-05-05 11:25 ` Maxime Ripard [this message]
2023-06-13 11:15 ` [PATCH v4 03/68] clk: Move no reparent case into a separate function Marek Szyprowski
2023-06-13 12:15 ` Marek Szyprowski
2023-06-13 12:29 ` Maxime Ripard
2023-05-05 11:25 ` [PATCH v4 04/68] clk: Introduce clk_hw_determine_rate_no_reparent() Maxime Ripard
2023-05-05 11:25 ` [PATCH v4 45/68] rtc: sun6i: Add a determine_rate hook Maxime Ripard
2023-05-05 18:46 ` Jernej Škrabec
2023-05-05 11:26 ` [PATCH v4 68/68] clk: Forbid to register a mux without determine_rate Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221018-clk-range-checks-fixes-v4-3-971d5077e7d2@cerno.tech \
--to=maxime@cerno.tech \
--cc=a.zummo@towertech.it \
--cc=abelvesa@kernel.org \
--cc=afaerber@suse.de \
--cc=airlied@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=claudiu.beznea@microchip.com \
--cc=daniel@ffwll.ch \
--cc=david@lechnology.com \
--cc=dinguyen@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=jcmvbkbc@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kernel@pengutronix.de \
--cc=kishon@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-actions@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-mips@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mani@kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=miles.chen@mediatek.com \
--cc=mperttunen@nvidia.com \
--cc=msp@baylibre.com \
--cc=mturquette@baylibre.com \
--cc=nicolas.ferre@microchip.com \
--cc=nsekhar@ti.com \
--cc=orsonzhai@gmail.com \
--cc=patches@opensource.cirrus.com \
--cc=paul@crapouillou.net \
--cc=pdeschrijver@nvidia.com \
--cc=peng.fan@nxp.com \
--cc=perex@perex.cz \
--cc=pgaikwad@nvidia.com \
--cc=rf@opensource.cirrus.com \
--cc=s.hauer@pengutronix.de \
--cc=samuel@sholland.org \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tiwai@suse.com \
--cc=ulf.hansson@linaro.org \
--cc=vkoul@kernel.org \
--cc=wens@csie.org \
--cc=wenst@chromium.org \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox