Re: [PATCH] cpufreq: Skip all governor-related actions for cpufreq_suspended set

From: Viresh Kumar
Date: Thu Apr 07 2016 - 08:05:16 EST


On 07-04-16, 13:44, Rafael J. Wysocki wrote:
> I'm not sure I'm following.
>
> Without this patch fast switch is disabled when we offline the nonboot
> CPUs during suspend, because cpufreq_exit_governor() runs then, but
> the cpufreq_governor() called by it does nothing. Also
> cpufreq_governor() during nonboot CPUs online does nothing.
>
> That has to be made consistent somehow. This patch is one way.
> Another way would be to disable fast switch from the governor ->exit
> callback, but the net result would be the same.

Actually things are working fine today by chance IMO, because we don't
free the policy structures anymore while we offline CPUs.

Otherwise, policy->governor_data would have been lost together with
the policy, and governor wouldn't have worked properly after resume.

What we are doing today is something like this:

Suspend
-------

-> cpufreq_suspend()
-> STOP governor
-> cpufreq_suspended = true

-> Offline non-boot CPUs
-> cpufreq_offline()
-> SKIP calling EXIT governor (governor had allocated few
resources earlier)

Resume
------

-> Bring back non-boot CPUs
-> cpufreq_online()
-> SKIP calling INIT governor (policy->governor_data doesn't get
reset, luckily)

-> cpufreq_resume()
-> cpufreq_suspended = false
-> START governor


That's *ugly* and it works by chance, unless I am misreading it
completely.

One of the solutions to get this cleaned is to stop checking for
cpufreq_suspended flag in cpufreq_governor() and put that *only* in
places where we are trying to interact with the hardware. And that
essentially is the callbacks provided by the cpufreq drivers. So,
ignore calling cpufreq-driver callbacks if cpufreq_suspended is true.

--
viresh