From: Chanwoo Choi <cw00.choi@samsung.com>
To: Viresh Kumar <viresh.kumar@linaro.org>,
Rafael Wysocki <rjw@rjwysocki.net>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
Stephen Boyd <sboyd@codeaurora.org>,
nm@ti.com, Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH] devfreq: rk3399_dmc: Don't use OPP structures outside of RCU locks
Date: Fri, 02 Dec 2016 17:42:33 +0900 [thread overview]
Message-ID: <584133F9.4080006@samsung.com> (raw)
In-Reply-To: <22bf6dfc155a6a241c2ee4e2b44a615d0e82064d.1480588658.git.viresh.kumar@linaro.org>
Hi Viresh,
On 2016년 12월 01일 19:38, Viresh Kumar wrote:
> The OPP structures are abused to the best here, without understanding
> how the OPP core and RCU locks work.
>
> In short, the OPP pointer saved in 'rk3399_dmcfreq' can become invalid
> under your nose, as the OPP core may free it.
>
> Fix various abuses around OPP structures and calls.
>
> Compile tested only.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> I would like it to go via the PM tree. Perhaps that's already the
> default tree for this.
>
> drivers/devfreq/rk3399_dmc.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c
> index 5063ac1a5939..cf14631b1945 100644
> --- a/drivers/devfreq/rk3399_dmc.c
> +++ b/drivers/devfreq/rk3399_dmc.c
> @@ -80,7 +80,6 @@ struct rk3399_dmcfreq {
> struct regulator *vdd_center;
> unsigned long rate, target_rate;
> unsigned long volt, target_volt;
> - struct dev_pm_opp *curr_opp;
> };
>
> static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq,
> @@ -102,9 +101,6 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq,
> target_rate = dev_pm_opp_get_freq(opp);
> target_volt = dev_pm_opp_get_voltage(opp);
>
> - dmcfreq->rate = dev_pm_opp_get_freq(dmcfreq->curr_opp);
> - dmcfreq->volt = dev_pm_opp_get_voltage(dmcfreq->curr_opp);
> -
> rcu_read_unlock();
>
> if (dmcfreq->rate == target_rate)
dmcfreq->rate is used on here.
Maybe struct rk3399_dmcfreq need to add the new 'curr_freq' field.
> @@ -165,7 +161,9 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq,
> if (err)
> dev_err(dev, "Cannot to set vol %lu uV\n", target_volt);
>
> - dmcfreq->curr_opp = opp;
> + dmcfreq->rate = target_rate;
> + dmcfreq->volt = target_volt;
> +
> out:
> mutex_unlock(&dmcfreq->lock);
> return err;
> @@ -431,8 +429,9 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
> rcu_read_unlock();
> return PTR_ERR(opp);
> }
> + dmcfreq->rate = dev_pm_opp_get_freq(opp);
> + dmcfreq->volt = dev_pm_opp_get_voltage(opp);
> rcu_read_unlock();
> - data->curr_opp = opp;
>
> rk3399_devfreq_dmc_profile.initial_freq = data->rate;
>
>
--
Best Regards,
Chanwoo Choi
next prev parent reply other threads:[~2016-12-02 8:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20161201103813epcas4p116430ac17cea842a7f09b35f0969ccb0@epcas4p1.samsung.com>
2016-12-01 10:38 ` [PATCH] devfreq: rk3399_dmc: Don't use OPP structures outside of RCU locks Viresh Kumar
2016-12-02 8:42 ` Chanwoo Choi [this message]
2016-12-02 9:00 ` Viresh Kumar
2016-12-02 13:21 ` Chanwoo Choi
2016-12-02 13:26 ` Chanwoo Choi
2016-12-02 13:53 ` Viresh Kumar
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=584133F9.4080006@samsung.com \
--to=cw00.choi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=nm@ti.com \
--cc=rjw@rjwysocki.net \
--cc=sboyd@codeaurora.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@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.