Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d30b895f authored by Taniya Das's avatar Taniya Das Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarTaniya Das <tdas@codeaurora.org>
parent cc6ef92a
Loading
Loading
Loading
Loading
+44 −34
Original line number Diff line number Diff line
@@ -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,6 +3487,13 @@ static int __clk_core_init(struct clk_core *core)
	if (core->flags & CLK_ENABLE_HAND_OFF) {
		unsigned long 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);
@@ -3494,6 +3503,7 @@ static int __clk_core_init(struct clk_core *core)
			clk_core_enable(core);
			clk_enable_unlock(flags);
		}
	}

	kref_init(&core->ref);
out: