From: Tomeu Vizoso <tomeu.vizoso@collabora.com> To: Mike Turquette <mturquette@linaro.org> Cc: Stephen Warren <swarren@wwwdotorg.org>, Thierry Reding <thierry.reding@gmail.com>, tomasz.figa@gmail.com, Peter De Schrijver <pdeschrijver@nvidia.com>, rabin@rab.in, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Javier Martinez Canillas <javier.martinez@collabora.co.uk>, Tomeu Vizoso <tomeu.vizoso@collabora.com> Subject: [PATCH v10 6/9] clk: Warn of unbalanced clk_prepare() calls Date: Tue, 9 Sep 2014 16:06:49 +0200 [thread overview] Message-ID: <1410271612-27389-4-git-send-email-tomeu.vizoso@collabora.com> (raw) In-Reply-To: <1410271612-27389-1-git-send-email-tomeu.vizoso@collabora.com> The warning will display the clock user that is trying to unprepare the clock, and the location of the last unprepare call. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- v8: * Patch added --- drivers/clk/clk.c | 22 ++++++++++++++++++++-- include/linux/clk-private.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 3a961c6..3018f37 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -834,7 +834,17 @@ void clk_unprepare(struct clk *clk_user) if (IS_ERR_OR_NULL(clk_user)) return; - clk_provider_unprepare(clk_to_clk_core(clk_user)); + clk_prepare_lock(); + if (!WARN(clk_user->prepare_count == 0, + "incorrect unprepare clk dev %s con %s last caller of unprepare %pF\n", + clk_user->dev_id, clk_user->con_id, clk_user->last_unprepare)) { + + clk_user->last_unprepare = __builtin_return_address(0); + clk_user->prepare_count--; + + __clk_unprepare(clk_to_clk_core(clk_user)); + } + clk_prepare_unlock(); } EXPORT_SYMBOL_GPL(clk_unprepare); @@ -890,10 +900,18 @@ EXPORT_SYMBOL_GPL(clk_provider_prepare); */ int clk_prepare(struct clk *clk_user) { + int ret; + if (!clk_user) return 0; - return clk_provider_prepare(clk_to_clk_core(clk_user)); + clk_prepare_lock(); + ret = __clk_prepare(clk_to_clk_core(clk_user)); + if (!ret) + clk_user->prepare_count++; + clk_prepare_unlock(); + + return ret; } EXPORT_SYMBOL_GPL(clk_prepare); diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h index 8126046..cf93bde 100644 --- a/include/linux/clk-private.h +++ b/include/linux/clk-private.h @@ -64,6 +64,9 @@ struct clk { unsigned int enable_count; void *last_disable; + unsigned int prepare_count; + void *last_unprepare; + unsigned long floor_constraint; unsigned long ceiling_constraint; struct hlist_node child_node; -- 1.9.3
WARNING: multiple messages have this Message-ID (diff)
From: tomeu.vizoso@collabora.com (Tomeu Vizoso) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v10 6/9] clk: Warn of unbalanced clk_prepare() calls Date: Tue, 9 Sep 2014 16:06:49 +0200 [thread overview] Message-ID: <1410271612-27389-4-git-send-email-tomeu.vizoso@collabora.com> (raw) In-Reply-To: <1410271612-27389-1-git-send-email-tomeu.vizoso@collabora.com> The warning will display the clock user that is trying to unprepare the clock, and the location of the last unprepare call. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- v8: * Patch added --- drivers/clk/clk.c | 22 ++++++++++++++++++++-- include/linux/clk-private.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 3a961c6..3018f37 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -834,7 +834,17 @@ void clk_unprepare(struct clk *clk_user) if (IS_ERR_OR_NULL(clk_user)) return; - clk_provider_unprepare(clk_to_clk_core(clk_user)); + clk_prepare_lock(); + if (!WARN(clk_user->prepare_count == 0, + "incorrect unprepare clk dev %s con %s last caller of unprepare %pF\n", + clk_user->dev_id, clk_user->con_id, clk_user->last_unprepare)) { + + clk_user->last_unprepare = __builtin_return_address(0); + clk_user->prepare_count--; + + __clk_unprepare(clk_to_clk_core(clk_user)); + } + clk_prepare_unlock(); } EXPORT_SYMBOL_GPL(clk_unprepare); @@ -890,10 +900,18 @@ EXPORT_SYMBOL_GPL(clk_provider_prepare); */ int clk_prepare(struct clk *clk_user) { + int ret; + if (!clk_user) return 0; - return clk_provider_prepare(clk_to_clk_core(clk_user)); + clk_prepare_lock(); + ret = __clk_prepare(clk_to_clk_core(clk_user)); + if (!ret) + clk_user->prepare_count++; + clk_prepare_unlock(); + + return ret; } EXPORT_SYMBOL_GPL(clk_prepare); diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h index 8126046..cf93bde 100644 --- a/include/linux/clk-private.h +++ b/include/linux/clk-private.h @@ -64,6 +64,9 @@ struct clk { unsigned int enable_count; void *last_disable; + unsigned int prepare_count; + void *last_unprepare; + unsigned long floor_constraint; unsigned long ceiling_constraint; struct hlist_node child_node; -- 1.9.3
next prev parent reply other threads:[~2014-09-09 14:07 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-09-09 14:02 [PATCH v10 0/9] Per-user clock constraints Tomeu Vizoso 2014-09-09 14:02 ` Tomeu Vizoso 2014-09-09 14:02 ` [PATCH v10 1/9] clk: Add temporary mapping to the existing API Tomeu Vizoso 2014-09-09 14:02 ` Tomeu Vizoso 2014-09-09 14:04 ` [PATCH v10 2/9] clk: Move all drivers to use internal API Tomeu Vizoso 2014-09-09 14:04 ` Tomeu Vizoso 2014-09-09 19:12 ` Mike Turquette 2014-09-09 19:12 ` Mike Turquette 2014-09-09 19:25 ` Mike Turquette 2014-09-09 19:25 ` Mike Turquette 2014-09-10 1:53 ` Stephen Boyd 2014-09-10 1:53 ` Stephen Boyd 2014-09-10 8:38 ` Tomeu Vizoso 2014-09-10 8:38 ` Tomeu Vizoso 2014-09-10 13:20 ` Tomeu Vizoso 2014-09-10 13:20 ` Tomeu Vizoso 2014-09-10 7:36 ` Tomeu Vizoso 2014-09-10 7:36 ` Tomeu Vizoso 2014-09-09 14:06 ` [PATCH v10 3/9] clk: use struct clk only for external API Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso 2014-09-09 14:06 ` [PATCH v10 4/9] clk: per-user clock accounting for debug Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso 2014-09-09 14:06 ` [PATCH v10 5/9] clk: Add floor and ceiling constraints to clock rates Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso [this message] 2014-09-09 14:06 ` [PATCH v10 6/9] clk: Warn of unbalanced clk_prepare() calls Tomeu Vizoso 2014-09-09 14:06 ` [PATCH v10 7/9] clk: Take the prepare lock when updating the list of per-user clks Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso 2014-09-09 14:06 ` [PATCH v10 8/9] clk: Take the prepare lock when updating the per-user constraints Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso 2014-09-09 14:06 ` [PATCH v10 9/9] clk: Add docs about calling clk_put after clk_get_parent Tomeu Vizoso 2014-09-09 14:06 ` Tomeu Vizoso
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=1410271612-27389-4-git-send-email-tomeu.vizoso@collabora.com \ --to=tomeu.vizoso@collabora.com \ --cc=javier.martinez@collabora.co.uk \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mturquette@linaro.org \ --cc=pdeschrijver@nvidia.com \ --cc=rabin@rab.in \ --cc=swarren@wwwdotorg.org \ --cc=thierry.reding@gmail.com \ --cc=tomasz.figa@gmail.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.