From: Derek Basehore <dbasehore@chromium.org>
To: mturquette@baylibre.com
Cc: sboyd@kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org,
Derek Basehore <dbasehore@chromium.org>
Subject: [PATCH] clk: Remove global clk traversal on fetch parent index
Date: Thu, 20 Dec 2018 16:31:00 -0800 [thread overview]
Message-ID: <20181221003100.157581-1-dbasehore@chromium.org> (raw)
It's not required to traverse the entire clk tree when the parents
array contains a NULL value. You already have the parent clk_core
pointer, so you can just compare the parent->name and parent_names[i]
pointers.
In cases where clk names are never registered, this can be
a substantial power improvement since a mux having an unregistered
parent name will traverse the clk tree on every set_rate. This can
happen hundreds of times a second on CPU clks.
Change-Id: I85499d2e576249568ff508e424ca8d5009e6e2b1
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
---
drivers/clk/clk.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index af011974d4ec..57a95c713286 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1516,9 +1516,18 @@ static int clk_fetch_parent_index(struct clk_core *core,
if (!parent)
return -EINVAL;
- for (i = 0; i < core->num_parents; i++)
- if (clk_core_get_parent_by_index(core, i) == parent)
+ for (i = 0; i < core->num_parents; i++) {
+ if (core->parents[i] == parent)
+ return i;
+
+ if (core->parents[i])
+ continue;
+
+ if (!strcmp(parent->name, core->parent_names[i])) {
+ core->parents[i] = parent;
return i;
+ }
+ }
return -EINVAL;
}
--
2.20.1.415.g653613c723-goog
next reply other threads:[~2018-12-21 0:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 0:31 Derek Basehore [this message]
2018-12-21 20:34 ` Stephen Boyd
2019-01-24 19:17 ` Stephen Boyd
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=20181221003100.157581-1-dbasehore@chromium.org \
--to=dbasehore@chromium.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®