From: Stephen Boyd <sboyd@codeaurora.org>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: linux-kernel@vger.kernel.org,
"Mike Turquette" <mturquette@linaro.org>,
"Javier Martinez Canillas" <javier.martinez@collabora.co.uk>,
"Jonathan Corbet" <corbet@lwn.net>,
"Tony Lindgren" <tony@atomide.com>,
"Russell King" <linux@arm.linux.org.uk>,
"Ralf Baechle" <ralf@linux-mips.org>,
"Boris Brezillon" <boris.brezillon@free-electrons.com>,
"Emilio López" <emilio@elopez.com.ar>,
"Maxime Ripard" <maxime.ripard@free-electrons.com>,
"Tero Kristo" <t-kristo@ti.com>,
"Manuel Lauss" <manuel.lauss@gmail.com>,
"Alex Elder" <elder@linaro.org>,
"Matt Porter" <mporter@linaro.org>,
"Zhangfei Gao" <zhangfei.gao@linaro.org>,
"Haojian Zhuang" <haojian.zhuang@linaro.org>,
"Bintian Wang" <bintian.wang@huawei.com>,
"Chao Xie" <chao.xie@marvell.com>,
linux-doc@vger.kernel.org, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org
Subject: Re: [PATCH v10 3/3] clk: Add rate constraints to clocks
Date: Tue, 20 Jan 2015 16:46:55 -0800 [thread overview]
Message-ID: <20150121004655.GG27202@codeaurora.org> (raw)
In-Reply-To: <1421760306-6301-4-git-send-email-tomeu.vizoso@collabora.com>
It's looking fairly close. Thanks for keeping up with the review
comments.
On 01/20, Tomeu Vizoso wrote:
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index e867d6a..f241e27 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2143,6 +2280,10 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
> else
> clk->owner = NULL;
>
> + INIT_HLIST_HEAD(&clk->clks);
> +
> + hw->clk = __clk_create_clk(hw, NULL, NULL);
> +
> ret = __clk_init(dev, hw->clk);
> if (ret)
> return ERR_PTR(ret);
Don't we need to __clk_free_clk() here too?
> @@ -2151,6 +2292,19 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
> }
> EXPORT_SYMBOL_GPL(__clk_register);
>
> +static void __clk_free_clk(struct clk *clk)
> +{
> + struct clk_core *core = clk->core;
> +
> + clk_prepare_lock();
> + hlist_del(&clk->child_node);
> + clk_prepare_unlock();
> +
> + kfree(clk);
> +
> + clk_core_set_rate(core, core->req_rate);
Is it safe to call this during clock registration? I hope that it
will just bail out and do nothing because core->rate ==
core->req_rate. Maybe we can avoid this given my next comment
below.
> +}
> +
> /**
> * clk_register - allocate a new clock, register it and return an opaque cookie
> * @dev: device that is registering this clock
> @@ -2210,12 +2364,14 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
> }
> }
>
> + INIT_HLIST_HEAD(&clk->clks);
> +
> hw->clk = __clk_create_clk(hw, NULL, NULL);
> ret = __clk_init(dev, hw->clk);
> if (!ret)
> return hw->clk;
>
> - kfree(hw->clk);
> + __clk_free_clk(hw->clk);
> fail_parent_names_copy:
> while (--i >= 0)
> kfree(clk->parent_names[i]);
> @@ -2421,7 +2577,7 @@ void __clk_put(struct clk *clk)
> return;
>
> clk_core_put(clk->core);
> - kfree(clk);
> + __clk_free_clk(clk);
This doesn't look right. First we drop the core reference here
with clk_core_put() and then we call __clk_free_clk() which will
go and call clk_core_set_rate() on the clk->core which may or may
not exist anymore. I'd think we want to do these steps:
1. Unlink clk from clks list
2. Recalculate rate and set if changed
3. Drop kref on core with clk_core_put()
4. kfree the clk
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v10 3/3] clk: Add rate constraints to clocks
Date: Tue, 20 Jan 2015 16:46:55 -0800 [thread overview]
Message-ID: <20150121004655.GG27202@codeaurora.org> (raw)
In-Reply-To: <1421760306-6301-4-git-send-email-tomeu.vizoso@collabora.com>
It's looking fairly close. Thanks for keeping up with the review
comments.
On 01/20, Tomeu Vizoso wrote:
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index e867d6a..f241e27 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2143,6 +2280,10 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
> else
> clk->owner = NULL;
>
> + INIT_HLIST_HEAD(&clk->clks);
> +
> + hw->clk = __clk_create_clk(hw, NULL, NULL);
> +
> ret = __clk_init(dev, hw->clk);
> if (ret)
> return ERR_PTR(ret);
Don't we need to __clk_free_clk() here too?
> @@ -2151,6 +2292,19 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
> }
> EXPORT_SYMBOL_GPL(__clk_register);
>
> +static void __clk_free_clk(struct clk *clk)
> +{
> + struct clk_core *core = clk->core;
> +
> + clk_prepare_lock();
> + hlist_del(&clk->child_node);
> + clk_prepare_unlock();
> +
> + kfree(clk);
> +
> + clk_core_set_rate(core, core->req_rate);
Is it safe to call this during clock registration? I hope that it
will just bail out and do nothing because core->rate ==
core->req_rate. Maybe we can avoid this given my next comment
below.
> +}
> +
> /**
> * clk_register - allocate a new clock, register it and return an opaque cookie
> * @dev: device that is registering this clock
> @@ -2210,12 +2364,14 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
> }
> }
>
> + INIT_HLIST_HEAD(&clk->clks);
> +
> hw->clk = __clk_create_clk(hw, NULL, NULL);
> ret = __clk_init(dev, hw->clk);
> if (!ret)
> return hw->clk;
>
> - kfree(hw->clk);
> + __clk_free_clk(hw->clk);
> fail_parent_names_copy:
> while (--i >= 0)
> kfree(clk->parent_names[i]);
> @@ -2421,7 +2577,7 @@ void __clk_put(struct clk *clk)
> return;
>
> clk_core_put(clk->core);
> - kfree(clk);
> + __clk_free_clk(clk);
This doesn't look right. First we drop the core reference here
with clk_core_put() and then we call __clk_free_clk() which will
go and call clk_core_set_rate() on the clk->core which may or may
not exist anymore. I'd think we want to do these steps:
1. Unlink clk from clks list
2. Recalculate rate and set if changed
3. Drop kref on core with clk_core_put()
4. kfree the clk
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-01-21 0:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 13:24 [PATCH v10 0/3] Per-user clock constraints Tomeu Vizoso
2015-01-20 13:24 ` [PATCH v10 1/3] clk: Remove unneeded NULL checks Tomeu Vizoso
2015-01-20 13:24 ` [PATCH v10 2/3] clk: Make clk API return per-user struct clk instances Tomeu Vizoso
2015-01-20 13:24 ` Tomeu Vizoso
2015-01-21 0:14 ` Stephen Boyd
2015-01-21 0:14 ` Stephen Boyd
2015-01-20 13:24 ` [PATCH v10 3/3] clk: Add rate constraints to clocks Tomeu Vizoso
2015-01-20 13:24 ` Tomeu Vizoso
2015-01-21 0:46 ` Stephen Boyd [this message]
2015-01-21 0:46 ` Stephen Boyd
2015-01-21 0:15 ` [PATCH v10 0/3] Per-user clock constraints 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=20150121004655.GG27202@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=bintian.wang@huawei.com \
--cc=boris.brezillon@free-electrons.com \
--cc=chao.xie@marvell.com \
--cc=corbet@lwn.net \
--cc=elder@linaro.org \
--cc=emilio@elopez.com.ar \
--cc=haojian.zhuang@linaro.org \
--cc=javier.martinez@collabora.co.uk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=manuel.lauss@gmail.com \
--cc=maxime.ripard@free-electrons.com \
--cc=mporter@linaro.org \
--cc=mturquette@linaro.org \
--cc=ralf@linux-mips.org \
--cc=t-kristo@ti.com \
--cc=tomeu.vizoso@collabora.com \
--cc=tony@atomide.com \
--cc=zhangfei.gao@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 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.