* [PATCH v2] intel_pstate: Force setting target pstate when required.
@ 2015-06-02 4:12 Doug Smythies
2015-06-15 23:44 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Doug Smythies @ 2015-06-02 4:12 UTC (permalink / raw)
To: kristen, rjw, linux-pm; +Cc: dsmythies
During initialization and exit it is possible that the
target pstate might not actually be set. Furthermore,
the result can be that the driver and the processor
are out of synch and, under some conditions, the driver
might never send the processor the proper target pstate.
This patch adds a bypass or do_checks flag to the call to
intel_pstate_set_pstate. If bypass, then specifically
bypass clamp checks and the do not send if it is the
same as last time check. If do_checks, then, and as before,
do the current policy clamp checks, and do not do actual
send if the new target is the same as the old.
Signed-off-by: Doug Smythies <dsmythies@telus.net>
Reported-by: Marien Zwart <marien.zwart@gmail.com>
Reported-by: Alex Lochmann <alexander.lochmann@tu-dortmund.de>
Reported-by: Piotr Kołaczkowski <pkolaczk@gmail.com>
Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
Tested-by: Marien Zwart <marien.zwart@gmail.com>
Tested-by: Doug Smythies <dsmythies@telus.net>
---
drivers/cpufreq/intel_pstate.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 6414661..52c720c 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -33,6 +33,9 @@
#include <asm/cpu_device_id.h>
#include <asm/cpufeature.h>
+#define PSTATE_BYPASS_CHECKS false
+#define PSTATE_DO_CHECKS true
+
#define BYT_RATIOS 0x66a
#define BYT_VIDS 0x66b
#define BYT_TURBO_RATIOS 0x66c
@@ -704,19 +707,20 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
*min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf);
}
-static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
+static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate, bool mode)
{
int max_perf, min_perf;
- update_turbo_state();
+ if (mode == PSTATE_DO_CHECKS) {
+ update_turbo_state();
- intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
+ intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
- pstate = clamp_t(int, pstate, min_perf, max_perf);
-
- if (pstate == cpu->pstate.current_pstate)
- return;
+ pstate = clamp_t(int, pstate, min_perf, max_perf);
+ if (pstate == cpu->pstate.current_pstate)
+ return;
+ }
trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu);
cpu->pstate.current_pstate = pstate;
@@ -733,7 +737,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
if (pstate_funcs.get_vid)
pstate_funcs.get_vid(cpu);
- intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
+ intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, PSTATE_BYPASS_CHECKS);
}
static inline void intel_pstate_calc_busy(struct cpudata *cpu)
@@ -844,7 +848,7 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
ctl = pid_calc(pid, busy_scaled);
/* Negative values of ctl increase the pstate and vice versa */
- intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl);
+ intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl, PSTATE_DO_CHECKS);
}
static void intel_hwp_timer_func(unsigned long __data)
@@ -1007,7 +1011,7 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
if (hwp_active)
return;
- intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
+ intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate, PSTATE_BYPASS_CHECKS);
}
static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] intel_pstate: Force setting target pstate when required.
2015-06-02 4:12 [PATCH v2] intel_pstate: Force setting target pstate when required Doug Smythies
@ 2015-06-15 23:44 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2015-06-15 23:44 UTC (permalink / raw)
To: Doug Smythies; +Cc: kristen, linux-pm, dsmythies
On Monday, June 01, 2015 09:12:34 PM Doug Smythies wrote:
> During initialization and exit it is possible that the
> target pstate might not actually be set. Furthermore,
> the result can be that the driver and the processor
> are out of synch and, under some conditions, the driver
> might never send the processor the proper target pstate.
>
> This patch adds a bypass or do_checks flag to the call to
> intel_pstate_set_pstate. If bypass, then specifically
> bypass clamp checks and the do not send if it is the
> same as last time check. If do_checks, then, and as before,
> do the current policy clamp checks, and do not do actual
> send if the new target is the same as the old.
>
> Signed-off-by: Doug Smythies <dsmythies@telus.net>
> Reported-by: Marien Zwart <marien.zwart@gmail.com>
> Reported-by: Alex Lochmann <alexander.lochmann@tu-dortmund.de>
> Reported-by: Piotr Kołaczkowski <pkolaczk@gmail.com>
> Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
> Tested-by: Marien Zwart <marien.zwart@gmail.com>
> Tested-by: Doug Smythies <dsmythies@telus.net>
I've applied the patch with a couple of changes.
> ---
> drivers/cpufreq/intel_pstate.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 6414661..52c720c 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -33,6 +33,9 @@
> #include <asm/cpu_device_id.h>
> #include <asm/cpufeature.h>
>
> +#define PSTATE_BYPASS_CHECKS false
> +#define PSTATE_DO_CHECKS true
Most importantly, I've dropped these symbol definitions as in my opinion it is
just clear to use bool directly instead.
Please check the result at
http://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git/commit/?h=linux-next&id=6c1e45917dec5e7c99ba8125fd8cc50f6e482a21
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-15 23:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02 4:12 [PATCH v2] intel_pstate: Force setting target pstate when required Doug Smythies
2015-06-15 23:44 ` Rafael J. Wysocki
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).