Re: [RFC][PATCH] cpufreq: User/admin documentation update and consolidation

From: Rafael J. Wysocki
Date: Tue Feb 21 2017 - 19:56:07 EST

On Tuesday, February 21, 2017 10:30:10 AM Viresh Kumar wrote:
> On 20-02-17, 14:58, Rafael J. Wysocki wrote:
> > Yes, it is called for new and inactive policies.
> >
> > For new policies it has to populate policy->cpus (because otherwise the core
> > doesn't know what CPUs should be there), which quite arguably doesn't have
> > to (or even doesn't need to) be done for inactive policies (because they already
> > have policy->real_cpus and policy->related_cpus populated).
> > I would even argue that ->init() should not update policy->cpus for inactive
> > (but not new) policies.
> I agree, but I am not aware of any platforms that we have today which
> does any similar checks in ->init(). And I wouldn't encourage drivers
> to have such special handling at all. Why make it complex?

Well, IMO we should not invoke the same callback in two different cases and
then do tricks in the core to make one of them work. That's just too [edited]

At least it doesn't help to understand the code flow.

> The way you have written it earlier suggests that the drivers should
> check if the policy is active or not (by looking at related_cpus mask)
> and set the cpus mask only for new policies. I was just worried that
> new driver authors will actually try to write special code in init()
> for that and if we really want that to be the case.

That would not be a bug IMO. Some of them could just check related_cpus
and do nothing if it is set I suppose?

Anyway, this isn't a driver API document, so the description is not super-precise.