linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jun Nie <jun.nie@linaro.org>
To: sboyd@codeaurora.org, mturquette@baylibre.com, linux-clk@vger.kernel.org
Cc: shawn.guo@linaro.org, Jun Nie <jun.nie@linaro.org>
Subject: [PATCH] clk: emit warning if fail to get parent clk
Date: Mon, 28 Sep 2020 16:47:44 +0800	[thread overview]
Message-ID: <20200928084744.32478-1-jun.nie@linaro.org> (raw)

Emit warning if fail to get parent clk to expose potential issue earlier.
For example, clk_hw_get_rate() will return 0 for a clock without parent core
while parent number is not zero. This cause opp always think it is switching
frequency from 0 to some other frequency. Crash may happen if we switch
from high frequency to low frequency and lower CPU voltage before clk rate
switching.

Signed-off-by: Jun Nie <jun.nie@linaro.org>
---
 drivers/clk/clk.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 1a27e99ccb17..78b21b888e56 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -424,6 +424,7 @@ static void clk_core_fill_parent_index(struct clk_core *core, u8 index)
 {
 	struct clk_parent_map *entry = &core->parents[index];
 	struct clk_core *parent = ERR_PTR(-ENOENT);
+	int emit_warn = 0;
 
 	if (entry->hw) {
 		parent = entry->hw->core;
@@ -443,6 +444,12 @@ static void clk_core_fill_parent_index(struct clk_core *core, u8 index)
 	/* Only cache it if it's not an error */
 	if (!IS_ERR(parent))
 		entry->core = parent;
+	else if (parent != ERR_PTR(-EPROBE_DEFER))
+		emit_warn = 1;
+
+	if (emit_warn || (!parent && core->num_parents))
+		pr_warn("Fail to get indexed %d parent for clk %s.",
+			index, core->name);
 }
 
 static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core,
-- 
2.17.1


             reply	other threads:[~2020-09-28  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28  8:47 Jun Nie [this message]
2020-10-07 23:53 ` [PATCH] clk: emit warning if fail to get parent clk Stephen Boyd
2020-10-09  3:08   ` Jun Nie
2020-10-12 19:25     ` 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=20200928084744.32478-1-jun.nie@linaro.org \
    --to=jun.nie@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=shawn.guo@linaro.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;
as well as URLs for NNTP newsgroup(s).