From a37c367e1aa7d09d87c64faa7691d98a989228ca Mon Sep 17 00:00:00 2001 From: Alex Frid Date: Mon, 16 Jan 2017 18:28:38 -0800 Subject: [PATCH] clk: tegra: Add subtree change notifications Added PRE_SUBTREE_CHANGE and POST_SUBTREE_CHANGE that called before and after rate change is propagated down the sub-tree rooted in clk. This would allow children to be aware that next set rate operation is triggered by downward rate propagation, rather than direct set rate on a child clock. Bug 200267979 Change-Id: I6f2acbeca7cead0ecd385dcb2e58ced32448e998 Signed-off-by: Alex Frid Signed-off-by: Peter De Schrijver (cherry picked from commit 62f0d763fcb6c9d5bd9a373d22d802503ab0fdc5) Reviewed-on: https://git-master.nvidia.com/r/1558143 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Timo Alho Signed-off-by: Thomas Makin --- drivers/clk/clk.c | 10 ++++++++++ include/linux/clk.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index eeb36a866f52..99af6826ac14 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2554,6 +2554,13 @@ static void clk_change_rate(struct clk_core *core) if (core->ops->post_rate_change) core->ops->post_rate_change(core->hw, old_rate, core->rate); + /* + * Allow children to be aware that next set rate operation is triggered + * by downward rate propagation, rather than direct set rate on itself. + */ + if (core->notifier_count) + __clk_notify(core, PRE_SUBTREE_CHANGE, old_rate, core->rate); + /* * Use safe iteration, as change_rate can actually swap parents * for certain clock types. @@ -2569,6 +2576,9 @@ static void clk_change_rate(struct clk_core *core) if (core->new_child) clk_change_rate(core->new_child); + if (core->notifier_count) + __clk_notify(core, POST_SUBTREE_CHANGE, old_rate, core->rate); + clk_pm_runtime_put(core); } diff --git a/include/linux/clk.h b/include/linux/clk.h index 851a0f2cf42c..09064fcd4c76 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -35,10 +35,19 @@ struct of_phandle_args; * POST_RATE_CHANGE - called after the clk rate change has successfully * completed. Callbacks must always return NOTIFY_DONE or NOTIFY_OK. * + * PRE_SUBTREE_UPDATE - called before rate change is propagated down to + * sub-tree rooted in clk. Callbacks must always return NOTIFY_DONE + * or NOTIFY_OK. + * + * POST_SUBTREE_UPDATE - called after rate change is propagated down to + * sub-tree rooted in clk. Callbacks must always return NOTIFY_DONE + * or NOTIFY_OK. */ #define PRE_RATE_CHANGE BIT(0) #define POST_RATE_CHANGE BIT(1) #define ABORT_RATE_CHANGE BIT(2) +#define PRE_SUBTREE_CHANGE BIT(3) +#define POST_SUBTREE_CHANGE BIT(4) /** * struct clk_notifier - associate a clk with a notifier