Re: [PATCH 3/3] PM / OPP: Parse 'opp-<prop>-<name>' bindings

From: Viresh Kumar
Date: Wed Nov 18 2015 - 22:01:08 EST

On 18-11-15, 17:12, Stephen Boyd wrote:
> > + /* Operations on OPP structures must be done from within rcu locks */
> > + rcu_read_lock();
> > +
> > + dev_opp = _add_device_opp(dev);
> > + if (!dev_opp)
> > + return -ENOMEM;
> > +
> > + /* Do we already have a prop-name associated with dev_opp? */
> > + if (dev_opp->prop_name) {
> > + dev_err(dev, "%s: Already have prop-name %s\n", __func__,
> > + dev_opp->prop_name);
> > + ret = -EINVAL;
> > + goto unlock;
> > + }
> > +
> > + dev_opp->prop_name = kstrdup(name, GFP_KERNEL);
> I'm very confused now on the whole locking scheme. How can we be
> modifying the dev_opp under an rcu_read_lock? Don't we need to
> hold a stronger lock than a read lock because _add_device_opp()
> has already published the structure we're modifying here?

Yeah, it should be called from within the mutex lock we have.

> How is cpufreq-dt going to be changed to support this?

Maybe not at all :)

> I wonder
> if it would be better to hide these sorts of things behind a
> wrapper on top of the guts of dev_pm_opp_of_add_table(). That way
> the lifetime of the prop_name and hw_versions are contained to
> the same lifetime rules as the device's OPP table. Right now it
> seems like we're asking OPP initializers to call two or three
> functions in the right order to get the table initialized
> properly, which is not as easy as calling one function.

Yeah, so things should happen in order, but the caller for the new
routines can't be cpufreq-dt (well it can be, but then some
information is required via platform data).

These routines are supposed to be called by some sort of platform
specific code, as we need to read some efuses from hardware to know
about all this. And cpufreq-dt can't decide that.

Though, to keep things simple, we can put that information in platform
data, so that only cpufreq-dt does all the stuff in the correct order.

We can always add a wrapper which will add hardware-versions,
named-properties and finally initialize opp table. But I would like to
wait a bit for that.

Now that I need to update 2/3 again, due to your comments on this
patch, I will repost this series again instead of messing up here.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at