clk: move check for CLK_ENABLE_HAND_OFF at unused tree
The commit 04a0136aeea5 ("clk: introduce CLK_ENABLE_HAND_OFF flag")
assumes that the first time clock client calls a clk_prepare &
clk_enable, the clocks from that point of time could be on their own.
But there could be use cases which could have impacts due to this
handling. Moving the handoff counts for prepare and enable at unused
tree level.
Change-Id: I7d527571c2eb4d53d58d82126989bd673de12e2d
Signed-off-by: Taniya Das <tdas@codeaurora.org>
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
cc6ef92a18
commit
d30b895f21
@@ -1080,19 +1080,6 @@ int clk_prepare(struct clk *clk)
|
||||
if (!clk)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* setting CLK_ENABLE_HAND_OFF flag triggers this conditional
|
||||
*
|
||||
* need_handoff_prepare implies this clk was already prepared by
|
||||
* __clk_init. now we have a proper user, so unset the flag in our
|
||||
* internal bookkeeping. See CLK_ENABLE_HAND_OFF flag in clk-provider.h
|
||||
* for details.
|
||||
*/
|
||||
if (clk->core->need_handoff_prepare) {
|
||||
clk->core->need_handoff_prepare = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return clk_core_prepare_lock(clk->core);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(clk_prepare);
|
||||
@@ -1220,19 +1207,6 @@ int clk_enable(struct clk *clk)
|
||||
if (!clk)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* setting CLK_ENABLE_HAND_OFF flag triggers this conditional
|
||||
*
|
||||
* need_handoff_enable implies this clk was already enabled by
|
||||
* __clk_init. now we have a proper user, so unset the flag in our
|
||||
* internal bookkeeping. See CLK_ENABLE_HAND_OFF flag in clk-provider.h
|
||||
* for details.
|
||||
*/
|
||||
if (clk->core->need_handoff_enable) {
|
||||
clk->core->need_handoff_enable = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return clk_core_enable_lock(clk->core);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(clk_enable);
|
||||
@@ -1267,6 +1241,19 @@ static void clk_unprepare_unused_subtree(struct clk_core *core)
|
||||
hlist_for_each_entry(child, &core->children, child_node)
|
||||
clk_unprepare_unused_subtree(child);
|
||||
|
||||
/*
|
||||
* setting CLK_ENABLE_HAND_OFF flag triggers this conditional
|
||||
*
|
||||
* need_handoff_prepare implies this clk was already prepared by
|
||||
* __clk_init. now we have a proper user, so unset the flag in our
|
||||
* internal bookkeeping. See CLK_ENABLE_HAND_OFF flag in clk-provider.h
|
||||
* for details.
|
||||
*/
|
||||
if (core->need_handoff_prepare) {
|
||||
core->need_handoff_prepare = false;
|
||||
clk_core_unprepare(core);
|
||||
}
|
||||
|
||||
if (core->prepare_count)
|
||||
return;
|
||||
|
||||
@@ -1298,6 +1285,21 @@ static void clk_disable_unused_subtree(struct clk_core *core)
|
||||
hlist_for_each_entry(child, &core->children, child_node)
|
||||
clk_disable_unused_subtree(child);
|
||||
|
||||
/*
|
||||
* setting CLK_ENABLE_HAND_OFF flag triggers this conditional
|
||||
*
|
||||
* need_handoff_enable implies this clk was already enabled by
|
||||
* __clk_init. now we have a proper user, so unset the flag in our
|
||||
* internal bookkeeping. See CLK_ENABLE_HAND_OFF flag in clk-provider.h
|
||||
* for details.
|
||||
*/
|
||||
if (core->need_handoff_enable) {
|
||||
core->need_handoff_enable = false;
|
||||
flags = clk_enable_lock();
|
||||
clk_core_disable(core);
|
||||
clk_enable_unlock(flags);
|
||||
}
|
||||
|
||||
if (core->flags & CLK_OPS_PARENT_ENABLE)
|
||||
clk_core_prepare_enable(core->parent);
|
||||
|
||||
@@ -3485,14 +3487,22 @@ static int __clk_core_init(struct clk_core *core)
|
||||
if (core->flags & CLK_ENABLE_HAND_OFF) {
|
||||
unsigned long flags;
|
||||
|
||||
core->need_handoff_prepare = true;
|
||||
core->need_handoff_enable = true;
|
||||
ret = clk_core_prepare(core);
|
||||
if (ret)
|
||||
goto out;
|
||||
flags = clk_enable_lock();
|
||||
clk_core_enable(core);
|
||||
clk_enable_unlock(flags);
|
||||
/*
|
||||
* Few clocks might have hardware gating which would be
|
||||
* required to be ON before prepare/enabling the clocks. So
|
||||
* check if the clock has been turned ON earlier and we should
|
||||
* prepare/enable those clocks.
|
||||
*/
|
||||
if (clk_core_is_enabled(core)) {
|
||||
core->need_handoff_prepare = true;
|
||||
core->need_handoff_enable = true;
|
||||
ret = clk_core_prepare(core);
|
||||
if (ret)
|
||||
goto out;
|
||||
flags = clk_enable_lock();
|
||||
clk_core_enable(core);
|
||||
clk_enable_unlock(flags);
|
||||
}
|
||||
}
|
||||
|
||||
kref_init(&core->ref);
|
||||
|
||||
Reference in New Issue
Block a user