* [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers
[not found] <CGME20181002115219eucas1p23816d543c4dedb233406869c22713a95@eucas1p2.samsung.com>
@ 2018-10-02 11:52 ` Marek Szyprowski
2018-10-03 21:03 ` Sylwester Nawrocki
2018-10-08 2:47 ` Stephen Boyd
0 siblings, 2 replies; 5+ messages in thread
From: Marek Szyprowski @ 2018-10-02 11:52 UTC (permalink / raw)
To: linux-clk, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Chanwoo Choi,
Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz
clk_notifier_register() documentation states, that the provided notifier
callbacks associated with the notifier must not re-enter into the clk
framework by calling any top-level clk APIs. Fix this by replacing
clk_get_rate() calls with clk_hw_get_rate(), which is safe in this
context.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/clk/samsung/clk-cpu.c | 6 +++---
drivers/clk/samsung/clk-cpu.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c
index d2c99d8916b8..a5fddebbe530 100644
--- a/drivers/clk/samsung/clk-cpu.c
+++ b/drivers/clk/samsung/clk-cpu.c
@@ -152,7 +152,7 @@ static int exynos_cpuclk_pre_rate_change(struct clk_notifier_data *ndata,
struct exynos_cpuclk *cpuclk, void __iomem *base)
{
const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg;
- unsigned long alt_prate = clk_get_rate(cpuclk->alt_parent);
+ unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent);
unsigned long alt_div = 0, alt_div_mask = DIV_MASK;
unsigned long div0, div1 = 0, mux_reg;
unsigned long flags;
@@ -280,7 +280,7 @@ static int exynos5433_cpuclk_pre_rate_change(struct clk_notifier_data *ndata,
struct exynos_cpuclk *cpuclk, void __iomem *base)
{
const struct exynos_cpuclk_cfg_data *cfg_data = cpuclk->cfg;
- unsigned long alt_prate = clk_get_rate(cpuclk->alt_parent);
+ unsigned long alt_prate = clk_hw_get_rate(cpuclk->alt_parent);
unsigned long alt_div = 0, alt_div_mask = DIV_MASK;
unsigned long div0, div1 = 0, mux_reg;
unsigned long flags;
@@ -432,7 +432,7 @@ int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
else
cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;
- cpuclk->alt_parent = __clk_lookup(alt_parent);
+ cpuclk->alt_parent = __clk_get_hw(__clk_lookup(alt_parent));
if (!cpuclk->alt_parent) {
pr_err("%s: could not lookup alternate parent %s\n",
__func__, alt_parent);
diff --git a/drivers/clk/samsung/clk-cpu.h b/drivers/clk/samsung/clk-cpu.h
index d4b6b517fe1b..bd38c6aa3897 100644
--- a/drivers/clk/samsung/clk-cpu.h
+++ b/drivers/clk/samsung/clk-cpu.h
@@ -49,7 +49,7 @@ struct exynos_cpuclk_cfg_data {
*/
struct exynos_cpuclk {
struct clk_hw hw;
- struct clk *alt_parent;
+ struct clk_hw *alt_parent;
void __iomem *ctrl_base;
spinlock_t *lock;
const struct exynos_cpuclk_cfg_data *cfg;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers
2018-10-02 11:52 ` [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers Marek Szyprowski
@ 2018-10-03 21:03 ` Sylwester Nawrocki
2018-10-08 2:47 ` Stephen Boyd
1 sibling, 0 replies; 5+ messages in thread
From: Sylwester Nawrocki @ 2018-10-03 21:03 UTC (permalink / raw)
To: Marek Szyprowski
Cc: linux-clk, linux-samsung-soc, Sylwester Nawrocki, Chanwoo Choi,
Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz
On 10/02/2018 01:52 PM, Marek Szyprowski wrote:
> clk_notifier_register() documentation states, that the provided notifier
> callbacks associated with the notifier must not re-enter into the clk
> framework by calling any top-level clk APIs. Fix this by replacing
> clk_get_rate() calls with clk_hw_get_rate(), which is safe in this
> context.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Thanks for fixing this, I have applied the patch to samsung-clk tree.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers
2018-10-02 11:52 ` [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers Marek Szyprowski
2018-10-03 21:03 ` Sylwester Nawrocki
@ 2018-10-08 2:47 ` Stephen Boyd
2018-10-08 14:51 ` Marek Szyprowski
1 sibling, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2018-10-08 2:47 UTC (permalink / raw)
To: Marek Szyprowski, linux-clk, linux-samsung-soc
Cc: Marek Szyprowski, Sylwester Nawrocki, Chanwoo Choi,
Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz
Quoting Marek Szyprowski (2018-10-02 04:52:10)
> @@ -432,7 +432,7 @@ int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
> else
> cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;
>
> - cpuclk->alt_parent = __clk_lookup(alt_parent);
> + cpuclk->alt_parent = __clk_get_hw(__clk_lookup(alt_parent));
It would be nice to get rid of __clk_lookup() from here too. Please try
to do that if at all possible.
> if (!cpuclk->alt_parent) {
> pr_err("%s: could not lookup alternate parent %s\n",
> __func__, alt_parent);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers
2018-10-08 2:47 ` Stephen Boyd
@ 2018-10-08 14:51 ` Marek Szyprowski
2018-10-09 22:52 ` Stephen Boyd
0 siblings, 1 reply; 5+ messages in thread
From: Marek Szyprowski @ 2018-10-08 14:51 UTC (permalink / raw)
To: Stephen Boyd, linux-clk, linux-samsung-soc
Cc: Sylwester Nawrocki, Chanwoo Choi, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz
Hi Stephen,
On 2018-10-08 04:47, Stephen Boyd wrote:
> Quoting Marek Szyprowski (2018-10-02 04:52:10)
>> @@ -432,7 +432,7 @@ int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
>> else
>> cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;
>>
>> - cpuclk->alt_parent = __clk_lookup(alt_parent);
>> + cpuclk->alt_parent = __clk_get_hw(__clk_lookup(alt_parent));
> It would be nice to get rid of __clk_lookup() from here too. Please try
> to do that if at all possible.
So far it won't be possible to get rid of __clk_lookup() completely from
samsung/clk-cpu.c, because there is a need to register clk notifier for
CPU clock, but there is no clk_hw_notifier_register() api. I'm not sure if
this is the right way to add it.
> ...
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers
2018-10-08 14:51 ` Marek Szyprowski
@ 2018-10-09 22:52 ` Stephen Boyd
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2018-10-09 22:52 UTC (permalink / raw)
To: Marek Szyprowski, linux-clk, linux-samsung-soc
Cc: Sylwester Nawrocki, Chanwoo Choi, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz
Quoting Marek Szyprowski (2018-10-08 07:51:30)
> Hi Stephen,
>
> On 2018-10-08 04:47, Stephen Boyd wrote:
> > Quoting Marek Szyprowski (2018-10-02 04:52:10)
> >> @@ -432,7 +432,7 @@ int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
> >> else
> >> cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;
> >>
> >> - cpuclk->alt_parent = __clk_lookup(alt_parent);
> >> + cpuclk->alt_parent = __clk_get_hw(__clk_lookup(alt_parent));
> > It would be nice to get rid of __clk_lookup() from here too. Please try
> > to do that if at all possible.
>
> So far it won't be possible to get rid of __clk_lookup() completely from
> samsung/clk-cpu.c, because there is a need to register clk notifier for
> CPU clock, but there is no clk_hw_notifier_register() api. I'm not sure if
> this is the right way to add it.
>
Probably there needs to be some way to indicate that the alt_parent is
going here and then grab the clk_hw pointer to it. Instead of looking up
a clk by random string name.
I don't really care about the clk_notifier_register() API, that's fine.
Eventually I'd like to see that API not be used by clk provider drivers.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-09 22:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20181002115219eucas1p23816d543c4dedb233406869c22713a95@eucas1p2.samsung.com>
2018-10-02 11:52 ` [PATCH] clk: samsung: Use clk_hw API for calling clk framework from clk notifiers Marek Szyprowski
2018-10-03 21:03 ` Sylwester Nawrocki
2018-10-08 2:47 ` Stephen Boyd
2018-10-08 14:51 ` Marek Szyprowski
2018-10-09 22:52 ` Stephen Boyd
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.