From: Benjamin Bara <bbara93@gmail.com>
To: Maxime Ripard <mripard@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: Frank Oltmanns <frank@oltmanns.dev>,
Adam Ford <aford173@gmail.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Benjamin Bara <benjamin.bara@skidata.com>
Subject: [PATCH RFC 3/4] clk: introduce req_rate_tmp
Date: Mon, 02 Oct 2023 11:23:34 +0200 [thread overview]
Message-ID: <20231002-ccf-set-multiple-v1-3-2df5e9eb3738@skidata.com> (raw)
In-Reply-To: <20231002-ccf-set-multiple-v1-0-2df5e9eb3738@skidata.com>
From: Benjamin Bara <benjamin.bara@skidata.com>
A clock currently has a req_rate, which is required by the consumer, and
a next_rate, which is the outcoming rate of the ongoing clk_set_rate()
call. This commit introduces req_rate_tmp, which is a temporary required
rate for the ongoing change. This means, the clock is an ancestor of the
change trigger and a descendant of the top-most clock to change. This
helps us to identify if the clock is changed "by accident" (new_rate
set, req_rate_tmp not set).
Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
---
drivers/clk/clk.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 5f183cba300c..3e7dd97b71c3 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -68,6 +68,7 @@ struct clk_core {
u8 new_parent_index;
unsigned long rate;
unsigned long req_rate;
+ unsigned long req_rate_tmp;
unsigned long new_rate;
struct clk_core *new_parent;
struct clk_core *new_child;
@@ -2168,6 +2169,7 @@ static void clk_reset_temp_rates(struct clk_core *core)
struct clk_core *child;
core->new_rate = CLK_RATE_UNSET;
+ core->req_rate_tmp = CLK_RATE_UNSET;
hlist_for_each_entry(child, &core->children, child_node) {
clk_reset_temp_rates(child);
@@ -2256,8 +2258,17 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core,
out:
/* only set new_rates if we found a valid change path */
- if (top)
+ if (top) {
+ /*
+ * The current clock is an ancestor of the trigger and therefore
+ * is a clock which needs to be changed in this run. Clocks
+ * with new_rate set but req_rate_tmp unset are changed "by
+ * accident". On these clocks, the new_rate potentially
+ * conflicts with req_rate.
+ */
+ core->req_rate_tmp = new_rate;
clk_calc_subtree(core, new_rate, parent, p_index);
+ }
return top;
}
@@ -3917,7 +3928,7 @@ static int __clk_core_init(struct clk_core *core)
else
rate = 0;
core->rate = rate;
- core->req_rate = CLK_RATE_UNSET;
+ core->req_rate = core->req_rate_tmp = CLK_RATE_UNSET;
core->new_rate = CLK_RATE_UNSET;
/*
--
2.34.1
next prev parent reply other threads:[~2023-10-02 9:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 9:23 [PATCH RFC 0/4] clk: re-set required rates during clk_set_rate() Benjamin Bara
2023-10-02 9:23 ` [PATCH RFC 1/4] clk: only set req_rate if it is set by consumer Benjamin Bara
2023-10-02 9:23 ` [PATCH RFC 2/4] clk: reset new_rates for next run Benjamin Bara
2023-10-02 9:23 ` Benjamin Bara [this message]
2023-10-02 9:23 ` [PATCH RFC 4/4] clk: consider rates when calculating subtree Benjamin Bara
2023-10-02 12:26 ` [PATCH RFC 0/4] clk: re-set required rates during clk_set_rate() Maxime Ripard
2023-10-03 7:44 ` Benjamin Bara
2023-10-03 11:33 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231002-ccf-set-multiple-v1-3-2df5e9eb3738@skidata.com \
--to=bbara93@gmail.com \
--cc=aford173@gmail.com \
--cc=benjamin.bara@skidata.com \
--cc=frank@oltmanns.dev \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox