LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux
@ 2018-04-09 13:59 Jerome Brunet
2018-04-09 13:59 ` [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux Jerome Brunet
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jerome Brunet @ 2018-04-09 13:59 UTC (permalink / raw)
To: Stephen Boyd, Michael Turquette, Neil Armstrong
Cc: Jerome Brunet, Kevin Hilman, linux-clk, linux-kernel, linux-amlogic
CLK_MUX_ROUND_CLOSEST is part of clk_mux and meson's clk_regmap
documentation, so it should be honored by the determine_rate() callback.
It is note the case ATM. The series fixes this problem.
Jerome Brunet (2):
clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux
clk: meson: honor CLK_MUX_ROUND_CLOSEST in clk_regmap
drivers/clk/clk-mux.c | 10 +++++++++-
drivers/clk/clk.c | 7 ++++---
drivers/clk/meson/clk-regmap.c | 11 ++++++++++-
include/linux/clk-provider.h | 3 +++
4 files changed, 26 insertions(+), 5 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux
2018-04-09 13:59 [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Jerome Brunet
@ 2018-04-09 13:59 ` Jerome Brunet
2018-04-24 14:04 ` Ezequiel Garcia
2018-04-09 13:59 ` [PATCH 2/2] clk: meson: honor CLK_MUX_ROUND_CLOSEST in clk_regmap Jerome Brunet
2018-04-16 16:24 ` [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Stephen Boyd
2 siblings, 1 reply; 6+ messages in thread
From: Jerome Brunet @ 2018-04-09 13:59 UTC (permalink / raw)
To: Stephen Boyd, Michael Turquette, Neil Armstrong
Cc: Jerome Brunet, Kevin Hilman, linux-clk, linux-kernel, linux-amlogic
CLK_MUX_ROUND_CLOSEST is part of the clk_mux documentation but clk_mux
directly calls __clk_mux_determine_rate(), which overrides the flag.
As result, if clk_mux is instantiated with CLK_MUX_ROUND_CLOSEST, the
flag will be ignored and the clock rounded down.
To solve this, this patch expose clk_mux_determine_rate_flags() in the
clk-provider API and uses it in the determine_rate() callback of clk_mux.
Fixes: 15a02c1f6dd7 ("clk: Add __clk_mux_determine_rate_closest")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/clk-mux.c | 10 +++++++++-
drivers/clk/clk.c | 7 ++++---
include/linux/clk-provider.h | 3 +++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index ac4a042f8658..1628b93655ed 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -112,10 +112,18 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
return 0;
}
+static int clk_mux_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
+{
+ struct clk_mux *mux = to_clk_mux(hw);
+
+ return clk_mux_determine_rate_flags(hw, req, mux->flags);
+}
+
const struct clk_ops clk_mux_ops = {
.get_parent = clk_mux_get_parent,
.set_parent = clk_mux_set_parent,
- .determine_rate = __clk_mux_determine_rate,
+ .determine_rate = clk_mux_determine_rate,
};
EXPORT_SYMBOL_GPL(clk_mux_ops);
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ea67ac81c6f9..7af555f0e60c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -426,9 +426,9 @@ static bool mux_is_better_rate(unsigned long rate, unsigned long now,
return now <= rate && now > best;
}
-static int
-clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
- unsigned long flags)
+int clk_mux_determine_rate_flags(struct clk_hw *hw,
+ struct clk_rate_request *req,
+ unsigned long flags)
{
struct clk_core *core = hw->core, *parent, *best_parent = NULL;
int i, num_parents, ret;
@@ -488,6 +488,7 @@ clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
return 0;
}
+EXPORT_SYMBOL_GPL(clk_mux_determine_rate_flags);
struct clk *__clk_lookup(const char *name)
{
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 210a890008f9..1d25e149c1c5 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -765,6 +765,9 @@ int __clk_mux_determine_rate(struct clk_hw *hw,
int __clk_determine_rate(struct clk_hw *core, struct clk_rate_request *req);
int __clk_mux_determine_rate_closest(struct clk_hw *hw,
struct clk_rate_request *req);
+int clk_mux_determine_rate_flags(struct clk_hw *hw,
+ struct clk_rate_request *req,
+ unsigned long flags);
void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent);
void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate,
unsigned long max_rate);
--
2.14.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] clk: meson: honor CLK_MUX_ROUND_CLOSEST in clk_regmap
2018-04-09 13:59 [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Jerome Brunet
2018-04-09 13:59 ` [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux Jerome Brunet
@ 2018-04-09 13:59 ` Jerome Brunet
2018-04-16 16:24 ` [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Stephen Boyd
2 siblings, 0 replies; 6+ messages in thread
From: Jerome Brunet @ 2018-04-09 13:59 UTC (permalink / raw)
To: Stephen Boyd, Michael Turquette, Neil Armstrong
Cc: Jerome Brunet, Kevin Hilman, linux-clk, linux-kernel, linux-amlogic
Using __clk_mux_determine_rate effectively ignores CLK_MUX_ROUND_CLOSEST
if set the related clk_regmap mux instance.
Use clk_mux_determine_rate_flags() to make sure the flag is honored.
Fixes: ea11dda9e091 ("clk: meson: add regmap clocks")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/meson/clk-regmap.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/meson/clk-regmap.c b/drivers/clk/meson/clk-regmap.c
index 3645fdb62343..ab7a3556f5b2 100644
--- a/drivers/clk/meson/clk-regmap.c
+++ b/drivers/clk/meson/clk-regmap.c
@@ -153,10 +153,19 @@ static int clk_regmap_mux_set_parent(struct clk_hw *hw, u8 index)
val << mux->shift);
}
+static int clk_regmap_mux_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
+{
+ struct clk_regmap *clk = to_clk_regmap(hw);
+ struct clk_regmap_mux_data *mux = clk_get_regmap_mux_data(clk);
+
+ return clk_mux_determine_rate_flags(hw, req, mux->flags);
+}
+
const struct clk_ops clk_regmap_mux_ops = {
.get_parent = clk_regmap_mux_get_parent,
.set_parent = clk_regmap_mux_set_parent,
- .determine_rate = __clk_mux_determine_rate,
+ .determine_rate = clk_regmap_mux_determine_rate,
};
EXPORT_SYMBOL_GPL(clk_regmap_mux_ops);
--
2.14.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux
2018-04-09 13:59 [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Jerome Brunet
2018-04-09 13:59 ` [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux Jerome Brunet
2018-04-09 13:59 ` [PATCH 2/2] clk: meson: honor CLK_MUX_ROUND_CLOSEST in clk_regmap Jerome Brunet
@ 2018-04-16 16:24 ` Stephen Boyd
2 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2018-04-16 16:24 UTC (permalink / raw)
To: Jerome Brunet, Michael Turquette, Neil Armstrong
Cc: Jerome Brunet, Kevin Hilman, linux-clk, linux-kernel, linux-amlogic
Quoting Jerome Brunet (2018-04-09 06:59:19)
> CLK_MUX_ROUND_CLOSEST is part of clk_mux and meson's clk_regmap
> documentation, so it should be honored by the determine_rate() callback.
>
> It is note the case ATM. The series fixes this problem.
I'll apply these for clk-fixes.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux
2018-04-09 13:59 ` [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux Jerome Brunet
@ 2018-04-24 14:04 ` Ezequiel Garcia
2018-04-25 9:59 ` Jerome Brunet
0 siblings, 1 reply; 6+ messages in thread
From: Ezequiel Garcia @ 2018-04-24 14:04 UTC (permalink / raw)
To: Jerome Brunet
Cc: Stephen Boyd, Michael Turquette, Neil Armstrong, Kevin Hilman,
linux-clk, linux-kernel, linux-amlogic
On 9 April 2018 at 10:59, Jerome Brunet <jbrunet@baylibre.com> wrote:
>
> CLK_MUX_ROUND_CLOSEST is part of the clk_mux documentation but clk_mux
> directly calls __clk_mux_determine_rate(), which overrides the flag.
> As result, if clk_mux is instantiated with CLK_MUX_ROUND_CLOSEST, the
> flag will be ignored and the clock rounded down.
>
> To solve this, this patch expose clk_mux_determine_rate_flags() in the
> clk-provider API and uses it in the determine_rate() callback of clk_mux.
>
> Fixes: 15a02c1f6dd7 ("clk: Add __clk_mux_determine_rate_closest")
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
> drivers/clk/clk-mux.c | 10 +++++++++-
> drivers/clk/clk.c | 7 ++++---
> include/linux/clk-provider.h | 3 +++
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
> index ac4a042f8658..1628b93655ed 100644
> --- a/drivers/clk/clk-mux.c
> +++ b/drivers/clk/clk-mux.c
> @@ -112,10 +112,18 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
> return 0;
> }
>
> +static int clk_mux_determine_rate(struct clk_hw *hw,
> + struct clk_rate_request *req)
> +{
> + struct clk_mux *mux = to_clk_mux(hw);
> +
> + return clk_mux_determine_rate_flags(hw, req, mux->flags);
> +}
> +
> const struct clk_ops clk_mux_ops = {
> .get_parent = clk_mux_get_parent,
> .set_parent = clk_mux_set_parent,
> - .determine_rate = __clk_mux_determine_rate,
> + .determine_rate = clk_mux_determine_rate,
> };
> EXPORT_SYMBOL_GPL(clk_mux_ops);
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index ea67ac81c6f9..7af555f0e60c 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -426,9 +426,9 @@ static bool mux_is_better_rate(unsigned long rate, unsigned long now,
> return now <= rate && now > best;
> }
>
> -static int
> -clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
> - unsigned long flags)
> +int clk_mux_determine_rate_flags(struct clk_hw *hw,
> + struct clk_rate_request *req,
> + unsigned long flags)
> {
> struct clk_core *core = hw->core, *parent, *best_parent = NULL;
> int i, num_parents, ret;
> @@ -488,6 +488,7 @@ clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
>
> return 0;
> }
> +EXPORT_SYMBOL_GPL(clk_mux_determine_rate_flags);
>
Why do we need to export this?
> struct clk *__clk_lookup(const char *name)
> {
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index 210a890008f9..1d25e149c1c5 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -765,6 +765,9 @@ int __clk_mux_determine_rate(struct clk_hw *hw,
> int __clk_determine_rate(struct clk_hw *core, struct clk_rate_request *req);
> int __clk_mux_determine_rate_closest(struct clk_hw *hw,
> struct clk_rate_request *req);
> +int clk_mux_determine_rate_flags(struct clk_hw *hw,
> + struct clk_rate_request *req,
> + unsigned long flags);
> void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent);
> void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate,
> unsigned long max_rate);
> --
> 2.14.3
>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Thanks!
--
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux
2018-04-24 14:04 ` Ezequiel Garcia
@ 2018-04-25 9:59 ` Jerome Brunet
0 siblings, 0 replies; 6+ messages in thread
From: Jerome Brunet @ 2018-04-25 9:59 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: Stephen Boyd, Michael Turquette, Neil Armstrong, Kevin Hilman,
linux-clk, linux-kernel, linux-amlogic
On Tue, 2018-04-24 at 11:04 -0300, Ezequiel Garcia wrote:
> > }
> > +EXPORT_SYMBOL_GPL(clk_mux_determine_rate_flags);
> >
>
> Why do we need to export this?
Because any driver implementing some type of mux may use this function, and the
driver could be a module. I have one in the pipe right now.
It is the same as __clk_determine_rate(), __clk_mux_determine_rate_closest()
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-04-25 10:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 13:59 [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Jerome Brunet
2018-04-09 13:59 ` [PATCH 1/2] clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux Jerome Brunet
2018-04-24 14:04 ` Ezequiel Garcia
2018-04-25 9:59 ` Jerome Brunet
2018-04-09 13:59 ` [PATCH 2/2] clk: meson: honor CLK_MUX_ROUND_CLOSEST in clk_regmap Jerome Brunet
2018-04-16 16:24 ` [PATCH 0/2] clk: honor CLK_MUX_ROUND_CLOSEST in mux Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).