Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1449288

Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit

From Jisheng Zhang <jszhang@marvell.com>
Newsgroups linux.kernel
Subject Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit
Date 2016-07-25 07:20 +0200
Message-ID <rYGt3-yl-7@gated-at.bofh.it> (permalink)
References <rXI3U-5Un-15@gated-at.bofh.it> <rXLuN-86Y-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit Jisheng Zhang <jszhang@marvell.com> - 2016-07-22 14:50 +0200
  Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-22 18:30 +0200
    Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit Jisheng Zhang <jszhang@marvell.com> - 2016-07-25 07:20 +0200
  Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit Jisheng Zhang <jszhang@marvell.com> - 2016-07-25 07:30 +0200
    Re: [PATCH] PM / OPP: optimize dev_pm_opp_set_rate() a bit Jisheng Zhang <jszhang@marvell.com> - 2016-07-25 08:20 +0200

csiph-web