From patchwork Wed Feb 5 23:27:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 11367377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C662D139A for ; Wed, 5 Feb 2020 23:28:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4E81214AF for ; Wed, 5 Feb 2020 23:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945297; bh=dw12aJGBOCJdLWAJqheCoPQcMOCtJwKsLjtTgt6MMVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CdT83dmHnRnA6N47KOEXpXxWH5jwtis+gN1IrW/yZGfT1eg/jMkr8nsoYDmZV/n9T +ocx4tOP2thhP2FRZcBVg9SbZEhCpyJLKuSHx7jSdncMLyx6sAjP34daf1clZW1/WM SxZTHlqqx/CAEAq2qc8iBuV+XoXqfR78F3SCGL5M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbgBEX2E (ORCPT ); Wed, 5 Feb 2020 18:28:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:38370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727482AbgBEX2E (ORCPT ); Wed, 5 Feb 2020 18:28:04 -0500 Received: from mail.kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1FB4B217BA; Wed, 5 Feb 2020 23:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945283; bh=dw12aJGBOCJdLWAJqheCoPQcMOCtJwKsLjtTgt6MMVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qPa8yQ3rZY9zQao7TbSyk8D9tmXff/r3WxMZTx+4cuK526Qjzz8Xb3P3ImilVgQu8 NLSyQEDEV3TXvZPW15U2QjK7AF+O7spZ7Xd1wqhyXXgk8wrfmrbzlZg+U4Fy7Skl2L jDQoWkC+oUrh+XOHyKddP+bjY4/mLsrtSW4mC5xU= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Douglas Anderson , Heiko Stuebner , Jerome Brunet Subject: [PATCH v2 1/4] clk: Don't cache errors from clk_ops::get_phase() Date: Wed, 5 Feb 2020 15:27:59 -0800 Message-Id: <20200205232802.29184-2-sboyd@kernel.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200205232802.29184-1-sboyd@kernel.org> References: <20200205232802.29184-1-sboyd@kernel.org> MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org We don't check for errors from clk_ops::get_phase() before storing away the result into the clk_core::phase member. This can lead to some fairly confusing debugfs information if these ops do return an error. Let's skip the store when this op fails to fix this. While we're here, move the locking outside of clk_core_get_phase() to simplify callers from the debugfs side. Cc: Douglas Anderson Cc: Heiko Stuebner Cc: Jerome Brunet Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 48 +++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d529ad67805c..26213e82f5f9 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2660,12 +2660,14 @@ static int clk_core_get_phase(struct clk_core *core) { int ret; - clk_prepare_lock(); + lockdep_assert_held(&prepare_lock); + if (!core->ops->get_phase) + return 0; + /* Always try to update cached phase if possible */ - if (core->ops->get_phase) - core->phase = core->ops->get_phase(core->hw); - ret = core->phase; - clk_prepare_unlock(); + ret = core->ops->get_phase(core->hw); + if (ret >= 0) + core->phase = ret; return ret; } @@ -2679,10 +2681,16 @@ static int clk_core_get_phase(struct clk_core *core) */ int clk_get_phase(struct clk *clk) { + int ret; + if (!clk) return 0; - return clk_core_get_phase(clk->core); + clk_prepare_lock(); + ret = clk_core_get_phase(clk->core); + clk_prepare_unlock(); + + return ret; } EXPORT_SYMBOL_GPL(clk_get_phase); @@ -2896,13 +2904,21 @@ static struct hlist_head *orphan_list[] = { static void clk_summary_show_one(struct seq_file *s, struct clk_core *c, int level) { - seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu %5d %6d\n", + int phase; + + seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ", level * 3 + 1, "", 30 - level * 3, c->name, c->enable_count, c->prepare_count, c->protect_count, - clk_core_get_rate(c), clk_core_get_accuracy(c), - clk_core_get_phase(c), - clk_core_get_scaled_duty_cycle(c, 100000)); + clk_core_get_rate(c), clk_core_get_accuracy(c)); + + phase = clk_core_get_phase(c); + if (phase >= 0) + seq_printf(s, "%5d", phase); + else + seq_puts(s, "-----"); + + seq_printf(s, " %6d\n", clk_core_get_scaled_duty_cycle(c, 100000)); } static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c, @@ -2939,6 +2955,7 @@ DEFINE_SHOW_ATTRIBUTE(clk_summary); static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level) { + int phase; unsigned long min_rate, max_rate; clk_core_get_boundaries(c, &min_rate, &max_rate); @@ -2952,7 +2969,9 @@ static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level) seq_printf(s, "\"min_rate\": %lu,", min_rate); seq_printf(s, "\"max_rate\": %lu,", max_rate); seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy(c)); - seq_printf(s, "\"phase\": %d,", clk_core_get_phase(c)); + phase = clk_core_get_phase(c); + if (phase >= 0) + seq_printf(s, "\"phase\": %d,", phase); seq_printf(s, "\"duty_cycle\": %u", clk_core_get_scaled_duty_cycle(c, 100000)); } @@ -3434,14 +3453,11 @@ static int __clk_core_init(struct clk_core *core) core->accuracy = 0; /* - * Set clk's phase. + * Set clk's phase by clk_core_get_phase() caching the phase. * Since a phase is by definition relative to its parent, just * query the current clock phase, or just assume it's in phase. */ - if (core->ops->get_phase) - core->phase = core->ops->get_phase(core->hw); - else - core->phase = 0; + clk_core_get_phase(core); /* * Set clk's duty cycle. From patchwork Wed Feb 5 23:28:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 11367373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37FE6924 for ; Wed, 5 Feb 2020 23:28:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16DA9214AF for ; Wed, 5 Feb 2020 23:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945294; bh=Vs2ad5m8Wzki1gkcDfV7JuENWCjWBcBgOwmxALy+SKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XsRXvU38tvQPYX0O8oKewYavulnr508INJjcWBDGMRSXTS1XscrC29PhUb2IAnl8L JqFrKD2rcq9gSUiixo7Mv6OTkvbR0tuAv0mkjSarIptVsg0/GCkNKjAoPb4L5AaT4O pUFfKGxjGff3a2RfW8W6TLu6xjxr9GHlk+lTAE4k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727565AbgBEX2E (ORCPT ); Wed, 5 Feb 2020 18:28:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:38386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727550AbgBEX2E (ORCPT ); Wed, 5 Feb 2020 18:28:04 -0500 Received: from mail.kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 798FD217F4; Wed, 5 Feb 2020 23:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945283; bh=Vs2ad5m8Wzki1gkcDfV7JuENWCjWBcBgOwmxALy+SKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sMxEOtkgJ/W9H2pRNp1aRL7EAtc8pB+UiR9JYSBfYGwo+SnfXNJLe9Pg/+yNTveYz PvkQzveY/Qn7LpjB5nRDrYjpzE5d8RG9yvGwYMS3cphkNAF39yoAgMfVl/VK7ZyuHD 5bpP0dQhB2oX9ifqURwYcJkaTCAPpSgGISKlQSn8= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Douglas Anderson , Heiko Stuebner , Jerome Brunet Subject: [PATCH v2 2/4] clk: Use 'parent' to shorten lines in __clk_core_init() Date: Wed, 5 Feb 2020 15:28:00 -0800 Message-Id: <20200205232802.29184-3-sboyd@kernel.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200205232802.29184-1-sboyd@kernel.org> References: <20200205232802.29184-1-sboyd@kernel.org> MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Some lines are getting long in this function. Let's move 'parent' up to the top of the function and use it in many places whenever there is a parent for a clk. This shortens some lines by avoiding core->parent-> indirections. Cc: Douglas Anderson Cc: Heiko Stuebner Cc: Jerome Brunet Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 26213e82f5f9..9ad950178d10 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3342,6 +3342,7 @@ static void clk_core_reparent_orphans_nolock(void) static int __clk_core_init(struct clk_core *core) { int ret; + struct clk_core *parent; unsigned long rate; if (!core) @@ -3413,7 +3414,7 @@ static int __clk_core_init(struct clk_core *core) goto out; } - core->parent = __clk_init_parent(core); + parent = core->parent = __clk_init_parent(core); /* * Populate core->parent if parent has already been clk_core_init'd. If @@ -3425,10 +3426,9 @@ static int __clk_core_init(struct clk_core *core) * clocks and re-parent any that are children of the clock currently * being clk_init'd. */ - if (core->parent) { - hlist_add_head(&core->child_node, - &core->parent->children); - core->orphan = core->parent->orphan; + if (parent) { + hlist_add_head(&core->child_node, &parent->children); + core->orphan = parent->orphan; } else if (!core->num_parents) { hlist_add_head(&core->child_node, &clk_root_list); core->orphan = false; @@ -3446,9 +3446,9 @@ static int __clk_core_init(struct clk_core *core) */ if (core->ops->recalc_accuracy) core->accuracy = core->ops->recalc_accuracy(core->hw, - __clk_get_accuracy(core->parent)); - else if (core->parent) - core->accuracy = core->parent->accuracy; + __clk_get_accuracy(parent)); + else if (parent) + core->accuracy = parent->accuracy; else core->accuracy = 0; @@ -3472,9 +3472,9 @@ static int __clk_core_init(struct clk_core *core) */ if (core->ops->recalc_rate) rate = core->ops->recalc_rate(core->hw, - clk_core_get_rate_nolock(core->parent)); - else if (core->parent) - rate = core->parent->rate; + clk_core_get_rate_nolock(parent)); + else if (parent) + rate = parent->rate; else rate = 0; core->rate = core->req_rate = rate; From patchwork Wed Feb 5 23:28:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 11367371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7559D924 for ; Wed, 5 Feb 2020 23:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A9C5214AF for ; Wed, 5 Feb 2020 23:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945286; bh=bKTzow6lnfsmvQ7jDptWZxY6H3I0ImNzPEkMhHjJfFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Oxzv5A3+8zxj2IwvDPKeBSC6L7KhA9Zv3gEbkYMqYvi7WtUKVT26quaojKogMSTVQ fw5+ex11r8yb21eFbIaaxB4M0+ZedG5tnm+cIjJkWuEgLsiuwDjdg7Mwuw3mFxsbBm bziGg/+MlLLRgIsba8AAl0UAP/sELm01mK0/Rilw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbgBEX2F (ORCPT ); Wed, 5 Feb 2020 18:28:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:38414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbgBEX2F (ORCPT ); Wed, 5 Feb 2020 18:28:05 -0500 Received: from mail.kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D31A9218AC; Wed, 5 Feb 2020 23:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945284; bh=bKTzow6lnfsmvQ7jDptWZxY6H3I0ImNzPEkMhHjJfFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rlBtackbzTq8xRdEjNNSDDnyUF/HYo+6bGp6XpBIL1ehppAzScTvapV3qmWEPebad loS77NuXFXfX8prBLA148vA/tFnehbHFik24APENoVAscanQ2PHATRzsbAVNa7LXUn adq31FMB7jHN0ujn3iSlLpITFmyz0sYBQNUDJP9Y= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Douglas Anderson , Heiko Stuebner , Jerome Brunet Subject: [PATCH v2 3/4] clk: Move rate and accuracy recalc to mostly consumer APIs Date: Wed, 5 Feb 2020 15:28:01 -0800 Message-Id: <20200205232802.29184-4-sboyd@kernel.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200205232802.29184-1-sboyd@kernel.org> References: <20200205232802.29184-1-sboyd@kernel.org> MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org There's some confusion about when recalc is done for the rate and accuracy clk consumer APIs in relation to the prepare lock being taken. Oddly enough, we take the lock again in debugfs APIs so that we can call the internal "clk_core" APIs to get these fields with any necessary recalculations. Instead of having this confusion, let's introduce a recalc variant of these two consumer APIs as internal helpers and call them from the consumer APIs and the debugfs code so that we don't take the lock more than once. Cc: Douglas Anderson Cc: Heiko Stuebner Cc: Jerome Brunet Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 9ad950178d10..87532e2d124a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -488,7 +488,7 @@ unsigned long clk_hw_get_rate(const struct clk_hw *hw) } EXPORT_SYMBOL_GPL(clk_hw_get_rate); -static unsigned long __clk_get_accuracy(struct clk_core *core) +static unsigned long clk_core_get_accuracy_no_lock(struct clk_core *core) { if (!core) return 0; @@ -1517,18 +1517,12 @@ static void __clk_recalc_accuracies(struct clk_core *core) __clk_recalc_accuracies(child); } -static long clk_core_get_accuracy(struct clk_core *core) +static long clk_core_get_accuracy_recalc(struct clk_core *core) { - unsigned long accuracy; - - clk_prepare_lock(); if (core && (core->flags & CLK_GET_ACCURACY_NOCACHE)) __clk_recalc_accuracies(core); - accuracy = __clk_get_accuracy(core); - clk_prepare_unlock(); - - return accuracy; + return clk_core_get_accuracy_no_lock(core); } /** @@ -1542,10 +1536,16 @@ static long clk_core_get_accuracy(struct clk_core *core) */ long clk_get_accuracy(struct clk *clk) { + long accuracy; + if (!clk) return 0; - return clk_core_get_accuracy(clk->core); + clk_prepare_lock(); + accuracy = clk_core_get_accuracy_recalc(clk->core); + clk_prepare_unlock(); + + return accuracy; } EXPORT_SYMBOL_GPL(clk_get_accuracy); @@ -1599,19 +1599,12 @@ static void __clk_recalc_rates(struct clk_core *core, unsigned long msg) __clk_recalc_rates(child, msg); } -static unsigned long clk_core_get_rate(struct clk_core *core) +static unsigned long clk_core_get_rate_recalc(struct clk_core *core) { - unsigned long rate; - - clk_prepare_lock(); - if (core && (core->flags & CLK_GET_RATE_NOCACHE)) __clk_recalc_rates(core, 0); - rate = clk_core_get_rate_nolock(core); - clk_prepare_unlock(); - - return rate; + return clk_core_get_rate_nolock(core); } /** @@ -1624,10 +1617,16 @@ static unsigned long clk_core_get_rate(struct clk_core *core) */ unsigned long clk_get_rate(struct clk *clk) { + unsigned long rate; + if (!clk) return 0; - return clk_core_get_rate(clk->core); + clk_prepare_lock(); + rate = clk_core_get_rate_recalc(clk->core); + clk_prepare_unlock(); + + return rate; } EXPORT_SYMBOL_GPL(clk_get_rate); @@ -2910,7 +2909,8 @@ static void clk_summary_show_one(struct seq_file *s, struct clk_core *c, level * 3 + 1, "", 30 - level * 3, c->name, c->enable_count, c->prepare_count, c->protect_count, - clk_core_get_rate(c), clk_core_get_accuracy(c)); + clk_core_get_rate_recalc(c), + clk_core_get_accuracy_recalc(c)); phase = clk_core_get_phase(c); if (phase >= 0) @@ -2965,10 +2965,10 @@ static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level) seq_printf(s, "\"enable_count\": %d,", c->enable_count); seq_printf(s, "\"prepare_count\": %d,", c->prepare_count); seq_printf(s, "\"protect_count\": %d,", c->protect_count); - seq_printf(s, "\"rate\": %lu,", clk_core_get_rate(c)); + seq_printf(s, "\"rate\": %lu,", clk_core_get_rate_recalc(c)); seq_printf(s, "\"min_rate\": %lu,", min_rate); seq_printf(s, "\"max_rate\": %lu,", max_rate); - seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy(c)); + seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy_recalc(c)); phase = clk_core_get_phase(c); if (phase >= 0) seq_printf(s, "\"phase\": %d,", phase); @@ -3446,7 +3446,7 @@ static int __clk_core_init(struct clk_core *core) */ if (core->ops->recalc_accuracy) core->accuracy = core->ops->recalc_accuracy(core->hw, - __clk_get_accuracy(parent)); + clk_core_get_accuracy_no_lock(parent)); else if (parent) core->accuracy = parent->accuracy; else From patchwork Wed Feb 5 23:28:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 11367375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AB19138D for ; Wed, 5 Feb 2020 23:28:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FA7B214AF for ; Wed, 5 Feb 2020 23:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945297; bh=46oZ7qfCkoMgiJNmlyL4gPed6RlcQ2p9W5//kGnmdW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=O2grZxk8ThBXUBg6NaSH6+zMJrbJOI4EGVSSHSxynoNMmEeuZic8zUOf21e25aRgw hHZQek2fpyvjvDUL8VfBbFdkkTwODATCaCE92c0IEXB1T+74SX2OP2O8DfI8zCYAjl TqpAguH1n5EfAUXFhgU4KOobKyECp6SCyELkLvwU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbgBEX2N (ORCPT ); Wed, 5 Feb 2020 18:28:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:38386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727562AbgBEX2E (ORCPT ); Wed, 5 Feb 2020 18:28:04 -0500 Received: from mail.kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3910021D7D; Wed, 5 Feb 2020 23:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580945284; bh=46oZ7qfCkoMgiJNmlyL4gPed6RlcQ2p9W5//kGnmdW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1qbTzrp3OYJjljGNXksFzohyeQKOG16ZA9ElJOJZYE0pYz99RY6HzML5gYQ89yjdL Ft1uzm50Nnv1XOe3XIqJV4vCS265FW8/kDT/HCP/xDGo2rq2kmokIHP8eEkYaKjY+a ucPOoZv8Ay10YX+ExJwfnXubPJgxHebXfD3P4Kxc= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Douglas Anderson , Heiko Stuebner , Jerome Brunet Subject: [PATCH v2 4/4] clk: Bail out when calculating phase fails during clk registration Date: Wed, 5 Feb 2020 15:28:02 -0800 Message-Id: <20200205232802.29184-5-sboyd@kernel.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200205232802.29184-1-sboyd@kernel.org> References: <20200205232802.29184-1-sboyd@kernel.org> MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Bail out of clk registration if we fail to get the phase for a clk that has a clk_ops::get_phase() callback. Print a warning too so that driver authors can easily figure out that some clk is unable to read back phase information at boot. Cc: Douglas Anderson Cc: Heiko Stuebner Suggested-by: Jerome Brunet Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 87532e2d124a..e9e83f7ae9e0 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3457,7 +3457,12 @@ static int __clk_core_init(struct clk_core *core) * Since a phase is by definition relative to its parent, just * query the current clock phase, or just assume it's in phase. */ - clk_core_get_phase(core); + ret = clk_core_get_phase(core); + if (ret < 0) { + pr_warn("%s: Failed to get phase for clk '%s'\n", __func__, + core->name); + goto out; + } /* * Set clk's duty cycle.