linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@marvell.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: vireshk@kernel.org, nm@ti.com, sboyd@codeaurora.org,
	rjw@rjwysocki.net, gregkh@linuxfoundation.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit
Date: Mon, 25 Jul 2016 13:12:52 +0800	[thread overview]
Message-ID: <20160725131252.0c583a4a@xhacker> (raw)
In-Reply-To: <20160722162151.GT3122@ubuntu>

Dear Viresh,

On Fri, 22 Jul 2016 09:21:51 -0700 Viresh Kumar  wrote:

> On 22-07-16, 20:42, Jisheng Zhang wrote:
> >  static int _set_opp_voltage(struct device *dev, struct regulator *reg,
> >  			    unsigned long u_volt, unsigned long u_volt_min,
> >  			    unsigned long u_volt_max)
> > @@ -586,9 +565,24 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
> >  		return -EINVAL;
> >  	}
> >  
> > -	clk = _get_opp_clk(dev);
> > -	if (IS_ERR(clk))
> > +	rcu_read_lock();
> > +
> > +	opp_table = _find_opp_table(dev);
> > +	if (IS_ERR(opp_table)) {
> > +		dev_err(dev, "%s: device opp doesn't exist\n", __func__);
> > +		rcu_read_unlock();
> > +		return PTR_ERR(opp_table);
> > +	}
> > +
> > +	clk = opp_table->clk;
> > +	if (IS_ERR(clk)) {
> > +		dev_err(dev, "%s: No clock available for the device\n",
> > +			__func__);
> > +		rcu_read_unlock();
> >  		return PTR_ERR(clk);
> > +	}
> > +
> > +	rcu_read_unlock();  
> 
> It is not _safe_ to use opp_table pointer after the rcu_read_unlock()

Oops, indeed. Thanks very much for pointing it out! Will fix it in v2, so
it seems we can only reduce the call of _find_opp_table to twice.

Thanks,
Jisheng

      reply	other threads:[~2016-07-25  5:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 12:42 [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit Jisheng Zhang
2016-07-22 14:30 ` kbuild test robot
2016-07-25  5:19   ` Jisheng Zhang
2016-07-25  6:05     ` Jisheng Zhang
2016-07-22 16:21 ` Viresh Kumar
2016-07-25  5:12   ` Jisheng Zhang [this message]

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=20160725131252.0c583a4a@xhacker \
    --to=jszhang@marvell.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@codeaurora.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vireshk@kernel.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).