Add P state driver for Intel Core Processors
Subsystems (2)
cover Add P state driver for Intel Core Processors
From: Dirk Brandewie <[email protected]>
This driver implements a scaling driver with an internal governor for Intel Core processors. The driver follows the same model as the Transmeta scaling driver (longrun.c) and implements the setpolicy() instead of target(). Scaling drivers that implement setpolicy() are assmuned to implement internal governors by the cpufreq core. All the logic for selecting the current P state is contained within the driver no external governor is used by the cpufreq core.
At the moment only Intel SandyBridge processors are supported. As testing on SandyBridge+ processors is completed support will be added to the driver.
New sysfs files for controlling P state selection have been added to /sys/devices/system/cpu/intel_pstate/
max_perf_pct: limits the maximum P state that will be requested by the driver stated as a percentage of the avail performance.
min_perf_pct: limits the minimum P state that will be requested by the driver stated as a percentage of the avail performance.
no_turbo: limits the driver to selecting P states below the turbo frequency range.
The units for these for these files are purposely abstract and stated in terms of available performance and not frequency. In idea that frequency can be set to a single frequency is a fiction for Intel Core processors. Even if the scaling driver selects a single P state the actual frequency the processor will run at is selected by the processor
This patch set is based on Rafael's bleeding edge branch commit df9d5b7c Patch 1:
Viresh's patch for the sake of completeness
patch 2-5:
Fix issues related to scaling drivers that implement the setpolicy() interface instead of target()
patch 6:
Fix cpufreq_stats to handle the scaling driver not exposing a frequency table while processing CPU_DOWN_PREPARE notification
Patch 7:
The driver itself
Dirk Brandewie (6):
cpufreq: Retrieve current frequency from scaling drivers with
internal governors
cpufreq: Only query drivers that implement cpufreq_driver.target()
cpufreq: Do not track governor name for scaling drivers with internal
governors.
cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using
setpolicy
cpufreq_stats: do not remove sysfs files if frequency table is not
present
cpufreq/x86: Add P-state driver for sandy bridge.
Viresh Kumar (1):
cpufreq: Don't remove sysfs link for policy->cpu
drivers/cpufreq/Kconfig.x86 | 18 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/cpufreq.c | 21 +- drivers/cpufreq/cpufreq_stats.c | 5 + drivers/cpufreq/intel_pstate.c | 829 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 870 insertions(+), 4 deletions(-) create mode 100644 drivers/cpufreq/intel_pstate.c
Signature · 1 line
1.7.7.6
PATCH 1/7 cpufreq: Don't remove sysfs link for policy->cpu
From: Viresh Kumar <[email protected]>
"cpufreq" directory in policy->cpu is never created using sysfs_create_link(), but using kobject_init_and_add(). And so we shouldn't call sysfs_remove_link() for policy->cpu(). sysfs stuff for policy->cpu is automatically removed when we call kobject_put() for dying policy.
--- drivers/cpufreq/cpufreq.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +3 -2
@@ -1058,7 +1058,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif cpus =cpumask_weight (data->cpus);cpumask_clear_cpu (cpu, data->cpus); -if (unlikely ((cpu == data->cpu) && (cpus >1 ))) { +if (cpu != data->cpu) { +sysfs_remove_link (&dev->kobj,"cpufreq" ); + }else if (cpus >1 ) {/* first sibling now owns the new sysfs dir */ cpu_dev =get_cpu_device (cpumask_first (data->cpus));sysfs_remove_link (&cpu_dev->kobj,"cpufreq" );
@@ -1083,7 +1085,6 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sifpr_debug ("%s: removing link, cpu: %d\n" , __func__, cpu);cpufreq_cpu_put (data);unlock_policy_rwsem_write (cpu); -sysfs_remove_link (&dev->kobj,"cpufreq" );/* If cpu is last user of policy, free policy */ if (cpus ==1 ) {
Signature · 1 line
1.7.7.6
Re: [PATCH 1/7] cpufreq: Don't remove sysfs link for policy->cpu
Quoted 9 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Viresh Kumar <[email protected]>
"cpufreq" directory in
policy->cpuis never created usingsysfs_create_link(), but usingkobject_init_and_add(). And so we shouldn't callsysfs_remove_link()forpolicy->cpu(). sysfs stuff forpolicy->cpuis automatically removed when we callkobject_put()for dying policy.Signed-off-by Viresh Kumar <[email protected]>Tested-by Dirk Brandewie <[email protected]>
Its already included by Rafael, don't include it in your next version:
commit 73bf0fc2b03d1f4fdada0ec430dc20bfb089cfd5
Author: Viresh Kumar <[email protected]> Date: Tue Feb 5 22:21:14 2013 +0100
cpufreq: Don't remove sysfs link for policy->cpu
"cpufreq" directory in policy->cpu is never created using sysfs_create_link(), but using kobject_init_and_add(). And so we shouldn't call sysfs_remove_link() for policy->cpu(). sysfs stuff for policy->cpu is automatically removed when we call kobject_put() for dying policy.
PATCH 2/7 cpufreq: Retrieve current frequency from scaling drivers with internal governors
In reply to [email protected]From: Dirk Brandewie <[email protected]>
Scaling drivers that implement the cpufreq_driver.setpolicy() versus the cpufreq_driver.target() interface do not set policy->cur.
Normally policy->cur is set during the call to cpufreq_driver.target() when the frequnecy request is made by the governor.
If the scaling driver implements cpufreq_driver.setpolicy() and cpufreq_driver.get() interfaces use cpufreq_driver.get() to retrieve the current frequency.
From: Dirk Brandewie <[email protected]>
Date: 2013-02-04 18:44:40 -0800
cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
There is an additional reference added to the driver in cpufreq_add_dev() that is removed in__cpufreq_governor() if the driver implements target(). Remove the last reference when the driver implements setpolicy()
--- drivers/cpufreq/cpufreq.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/cpufreq/cpufreq.c +7 -0
@@ -1181,6 +1181,13 @@ unsigned int cpufreq_quick_get(unsigned int cpu)struct cpufreq_policy *policy =cpufreq_cpu_get (cpu);unsigned int ret_freq =0 ; +if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) { + ret_freq = cpufreq_driver->get (cpu); +cpufreq_cpu_put (policy); +return ret_freq; + } +if (policy) { ret_freq = policy->cur;cpufreq_cpu_put (policy);
Signature · 1 line
1.7.7.6
Viresh Kumar
maintainerRe: [PATCH 2/7] cpufreq: Retrieve current frequency from scaling drivers with internal governors
Quoted 5 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
Scaling drivers that implement the
cpufreq_driver.setpolicy()versus thecpufreq_driver.target()interface do not setpolicy->cur.
Quoted 8 lines
Signed-off-by Dirk Brandewie <[email protected]>From: Dirk Brandewie <[email protected]>
Date: 2013-02-04 18:44:40 -0800cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
Signed-off-by Dirk Brandewie <[email protected]>
Wow!! Something happened here. :)
Viresh Kumar
maintainerRe: [PATCH 2/7] cpufreq: Retrieve current frequency from scaling drivers with internal governors
In reply to [email protected]Quoted 5 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
drivers/cpufreq/cpufreq.c +0
-0
drivers/cpufreq/cpufreq.c unsigned int cpufreq_quick_get(unsigned int cpu) · line 1190
Quoted 10 lines
drivers/cpufreq/cpufreq.c +7
-0@@ -1181,6 +1181,13 @@ unsigned int cpufreq_quick_get(unsigned int cpu)struct cpufreq_policy *policy =cpufreq_cpu_get (cpu);unsigned int ret_freq =0 ; +if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) { + ret_freq = cpufreq_driver->get (cpu); +cpufreq_cpu_put (policy); +return ret_freq; + } +
This was my comment on the last version:
"You are required to do cpufreq_cpu_put() in this case too... Better do cpufreq_cpu_get() after your check."
It still applies.
Re: [PATCH 2/7] cpufreq: Retrieve current frequency from scaling drivers with internal governors
Quoted 9 lines · Viresh Kumar
Quoted 8 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
drivers/cpufreq/cpufreq.c +0
-0@@ -1181,6 +1181,13 @@ unsigned int cpufreq_quick_get(unsigned int cpu)struct cpufreq_policy *policy =cpufreq_cpu_get (cpu);unsigned int ret_freq =0 ;
Quoted 8 lines
drivers/cpufreq/cpufreq.c unsigned int cpufreq_quick_get(unsigned int cpu) · line 1190
Quoted 7 lines
drivers/cpufreq/cpufreq.c +7
-0+if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) { + ret_freq = cpufreq_driver->get (cpu); +cpufreq_cpu_put (policy); +return ret_freq; + } +
How about this?
drivers/cpufreq/cpufreq.c +6 -1
@@ -1182,7 +1182,12 @@ unsigned int cpufreq_quick_get(unsigned int cpu)unsigned int ret_freq =0 ;if (policy) { - ret_freq = policy->cur; +if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) { + ret_freq = cpufreq_driver->get (cpu); + }else { + ret_freq = policy->cur; + }cpufreq_cpu_put (policy); }
Viresh Kumar
maintainerRe: [PATCH 2/7] cpufreq: Retrieve current frequency from scaling drivers with internal governors
Quoted 10 lines · Dirk Brandewie
How about this?
drivers/cpufreq/cpufreq.c +0
-0@@ -1182,7 +1182,12 @@ unsigned int cpufreq_quick_get(unsigned int cpu)unsigned int ret_freq =0 ;
drivers/cpufreq/cpufreq.c unsigned int cpufreq_quick_get(unsigned int cpu) · line 1193
Quoted 10 lines
drivers/cpufreq/cpufreq.c +6
-1if (policy) { - ret_freq = policy->cur; +if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) { + ret_freq = cpufreq_driver->get (cpu); + }else { + ret_freq = policy->cur; + }cpufreq_cpu_put (policy);
The problem is: You don't need to do get/put in your case at all.
Re: [PATCH 2/7] cpufreq: Retrieve current frequency from scaling drivers with internal governors
Quoted 14 lines · Viresh Kumar
Quoted 13 lines · Dirk Brandewie
How about this?
drivers/cpufreq/cpufreq.c +0
-1@@ -1182,7 +1182,12 @@ unsigned int cpufreq_quick_get(unsigned int cpu)unsigned int ret_freq =0 ;if (policy) { - ret_freq = policy->cur;
Quoted 7 lines
drivers/cpufreq/cpufreq.c unsigned int cpufreq_quick_get(unsigned int cpu) · line 1193
Quoted 7 lines
drivers/cpufreq/cpufreq.c +6
-0+if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) { + ret_freq = cpufreq_driver->get (cpu); + }else { + ret_freq = policy->cur; + }cpufreq_cpu_put (policy);
drivers/cpufreq/cpufreq.c +6 -1
@@ -1178,9 +1178,14 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,*/ unsigned int cpufreq_quick_get (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); +struct cpufreq_policy *policy;unsigned int ret_freq =0 ; +if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) +return cpufreq_driver->get (cpu); + + policy =cpufreq_cpu_get (cpu);if (policy) { ret_freq = policy->cur;cpufreq_cpu_put (policy);
Re: [PATCH 2/7] cpufreq: Retrieve current frequency from scaling drivers with internal governors
Quoted 20 lines · Dirk Brandewie
drivers/cpufreq/cpufreq.c +6
-1@@ -1178,9 +1178,14 @@ static void cpufreq_out_of_sync(unsigned int cpu,unsigned int old_freq, */ unsigned int cpufreq_quick_get (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); +struct cpufreq_policy *policy;unsigned int ret_freq =0 ; +if (cpufreq_driver && cpufreq_driver->setpolicy && + cpufreq_driver->get) +return cpufreq_driver->get (cpu); + + policy =cpufreq_cpu_get (cpu);
Quoted 3 lines
if (policy) {
ret_freq = policy->cur;
cpufreq_cpu_put(policy);PATCH 3/7 cpufreq: Only query drivers that implement cpufreq_driver.target()
In reply to [email protected]From: Dirk Brandewie <[email protected]>
Scaling drivers that implement cpufreq_driver.setpolicy() have internal governors and may/will change the current operating frequency very frequently this will cause cpufreq_out_of_sync() to be called every time. Only call cpufreq_driver.get() for drivers that implement cpufreq_driver.target()
--- drivers/cpufreq/cpufreq.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/cpufreq/cpufreq.c +1 -1
@@ -1787,7 +1787,7 @@ int cpufreq_update_policy(unsigned int cpu)/* BIOS might change freq behind our back -> ask driver for current freq and notify governors about a change */ -if (cpufreq_driver->get) { +if (cpufreq_driver->get && cpufreq_driver->target) { policy.cur = cpufreq_driver->get (cpu);if (!data->cur) {pr_debug ("Driver did not initialize current freq" );
Signature · 1 line
1.7.7.6
Viresh Kumar
maintainerRe: [PATCH 3/7] cpufreq: Only query drivers that implement cpufreq_driver.target()
Quoted 18 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
Scaling drivers that implement
cpufreq_driver.setpolicy()have internal governors and may/will change the current operating frequency very frequently this will causecpufreq_out_of_sync()to be called every time. Only callcpufreq_driver.get()for drivers that implementcpufreq_driver.target()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/cpufreq/cpufreq.c +0
-0
drivers/cpufreq/cpufreq.c int cpufreq_update_policy(unsigned int cpu) · line 1793
Quoted 8 lines
drivers/cpufreq/cpufreq.c +1
-1@@ -1787,7 +1787,7 @@ int cpufreq_update_policy(unsigned int cpu)/* BIOS might change freq behind our back -> ask driver for current freq and notify governors about a change */ -if (cpufreq_driver->get) { +if (cpufreq_driver->get && cpufreq_driver->target) { policy.cur = cpufreq_driver->get (cpu);if (!data->cur) {pr_debug ("Driver did not initialize current freq" );
I am really not liking copy-pasting my older comments here :(
"This would mean policy->cur has a garbage value. I don't really know how would other routine behave on this. Would it make sense to make policy->cur zero atleast?
"
Re: [PATCH 3/7] cpufreq: Only query drivers that implement cpufreq_driver.target()
Quoted 30 lines · Viresh Kumar
Quoted 18 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
Scaling drivers that implement
cpufreq_driver.setpolicy()have internal governors and may/will change the current operating frequency very frequently this will causecpufreq_out_of_sync()to be called every time. Only callcpufreq_driver.get()for drivers that implementcpufreq_driver.target()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/cpufreq/cpufreq.c +0
-0drivers/cpufreq/cpufreq.c int cpufreq_update_policy(unsigned int cpu) · line 1793
Quoted 8 lines
drivers/cpufreq/cpufreq.c +1
-1@@ -1787,7 +1787,7 @@ int cpufreq_update_policy(unsigned int cpu)/* BIOS might change freq behind our back -> ask driver for current freq and notify governors about a change */ -if (cpufreq_driver->get) { +if (cpufreq_driver->get && cpufreq_driver->target) { policy.cur = cpufreq_driver->get (cpu);if (!data->cur) {pr_debug ("Driver did not initialize current freq" );I am really not liking copy-pasting my older comments here :(
Quoted 5 lines
"This would mean
policy->curhas a garbage value. I don't really know how would other routine behave on this. Would it make sense to makepolicy->curzero atleast?
"
The driver implements get() and will return a valid value but the other components that track the current frequency will not have been notified about any change so there is nothing to be out of sync with. There is no reason to call cpufreq_out_of_sync() where the driver being used implements an internal governor.
--Dirk
Viresh Kumar
maintainerRe: [PATCH 3/7] cpufreq: Only query drivers that implement cpufreq_driver.target()
Quoted 41 lines · Dirk Brandewie
Quoted 35 lines · Viresh Kumar
Quoted 28 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
Scaling drivers that implement
cpufreq_driver.setpolicy()have internal governors and may/will change the current operating frequency very frequently this will causecpufreq_out_of_sync()to be called every time. Only callcpufreq_driver.get()for drivers that implementcpufreq_driver.target()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/cpufreq/cpufreq.c +0
-0@@ -1787,7 +1787,7 @@ int cpufreq_update_policy(unsigned int cpu)/* BIOS might change freq behind our back -> ask driver for current freq and notify governors about a change */
drivers/cpufreq/cpufreq.c +1
-1-if (cpufreq_driver->get) { +if (cpufreq_driver->get && cpufreq_driver->target) { policy.cur = cpufreq_driver->get (cpu);if (!data->cur) { pr_debug("Driver did not initialize currentQuoted 1 line
freq");
I am really not liking copy-pasting my older comments here :(
Quoted 5 lines
"This would mean
policy->curhas a garbage value. I don't really know how would other routine behave on this. Would it make sense to makepolicy->curzero atleast?
"
Quoted 6 lines
The driver implements
get()and will return a valid value but the other components that track the current frequency will not have been notified about any change so there is nothing to be out of sync with. There is no reason to callcpufreq_out_of_sync()where the driver being used implements an internal
governor.
Not sure if we are discussing the same issue. What i am saying is, with your patch we aren't calling following line:
Quoted 1 line
Quoted 1 line
Quoted 1 line
policy.cur = cpufreq_driver->get(cpu);
and policy was a local variable. Hence policy->cur is having a garbage value. policy->cur is used at multiple places in cpufreq.c . Please check everywhere if this garbage value doesn't break set_policy() type systems.
PATCH 4/7 cpufreq: Do not track governor name for scaling drivers with internal governors.
In reply to [email protected]From: Dirk Brandewie <[email protected]>
Scaling drivers that implement internal governors do not have governor structures assocaited with them. Only track the name of the governor associated with the CPU if the driver does not implement cpufreq_driver.setpolicy()
--- drivers/cpufreq/cpufreq.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/cpufreq/cpufreq.c +3 -1
@@ -1050,7 +1050,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif__cpufreq_governor (data,CPUFREQ_GOV_STOP );#ifdef CONFIG_HOTPLUG_CPU -strncpy (per_cpu (cpufreq_cpu_governor, cpu), data->governor->name, +if (!cpufreq_driver->setpolicy) +strncpy (per_cpu (cpufreq_cpu_governor, cpu), + data->governor->name,CPUFREQ_NAME_LEN );#endif
Signature · 1 line
1.7.7.6
Re: [PATCH 4/7] cpufreq: Do not track governor name for scaling drivers with internal governors.
Quoted 17 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
Scaling drivers that implement internal governors do not have governor structures assocaited with them. Only track the name of the governor associated with the CPU if the driver does not implement
cpufreq_driver.setpolicy()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)drivers/cpufreq/cpufreq.c +0
-0
drivers/cpufreq/cpufreq.c static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif · line 1056
Quoted 8 lines
drivers/cpufreq/cpufreq.c +3
-1@@ -1050,7 +1050,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif__cpufreq_governor (data,CPUFREQ_GOV_STOP );#ifdef CONFIG_HOTPLUG_CPU -strncpy (per_cpu (cpufreq_cpu_governor, cpu), data->governor->name, +if (!cpufreq_driver->setpolicy) +strncpy (per_cpu (cpufreq_cpu_governor, cpu), + data->governor->name,CPUFREQ_NAME_LEN );
PATCH 5/7 cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
In reply to [email protected]From: Dirk Brandewie <[email protected]>
There is an additional reference added to the driver in cpufreq_add_dev() that is removed in__cpufreq_governor() if the driver implements target(). Remove the last reference when the driver implements setpolicy()
--- drivers/cpufreq/cpufreq.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/cpufreq/cpufreq.c +3 -0
@@ -1049,6 +1049,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sifif (cpufreq_driver->target)__cpufreq_governor (data,CPUFREQ_GOV_STOP ); +if (cpufreq_driver->setpolicy) +cpufreq_cpu_put (data); +#ifdef CONFIG_HOTPLUG_CPU if (!cpufreq_driver->setpolicy) strncpy(per_cpu(cpufreq_cpu_governor, cpu),
Signature · 1 line
1.7.7.6
Viresh Kumar
maintainerRe: [PATCH 5/7] cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
Quoted 17 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
There is an additional reference added to the driver in
cpufreq_add_dev()that is removedin__cpufreq_governor()if the driver implementstarget(). Remove the last reference when the driver implementssetpolicy()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/cpufreq/cpufreq.c +0
-0
drivers/cpufreq/cpufreq.c static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif · line 1053
Quoted 5 lines
drivers/cpufreq/cpufreq.c +2
-0@@ -1049,6 +1049,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sifif (cpufreq_driver->target)__cpufreq_governor (data,CPUFREQ_GOV_STOP ); +if (cpufreq_driver->setpolicy) +cpufreq_cpu_put (data);
I don't understand this patch at all.. I grepped both cpufreq_cpu_get() & put() in bleeding-edge and found everything to be correct.
Can you please point me to the exact line numbers ?
Re: [PATCH 5/7] cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
Quoted 21 lines · Viresh Kumar
Quoted 20 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
There is an additional reference added to the driver in
cpufreq_add_dev()that is removedin__cpufreq_governor()if the driver implementstarget(). Remove the last reference when the driver implementssetpolicy()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/cpufreq/cpufreq.c +0
-0@@ -1049,6 +1049,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sifif (cpufreq_driver->target)__cpufreq_governor (data,CPUFREQ_GOV_STOP );
Quoted 8 lines
drivers/cpufreq/cpufreq.c static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif · line 1053
Quoted 2 lines
drivers/cpufreq/cpufreq.c +2
-0+if (cpufreq_driver->setpolicy) +cpufreq_cpu_put (data);I don't understand this patch at all.. I grepped both
cpufreq_cpu_get()&put()in bleeding-edge and found everything to be correct.Can you please point me to the exact line numbers ?
Line 878 in cpufreq_add_dev()
--Dirk
Viresh Kumar
maintainerRe: [PATCH 5/7] cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
Quoted 36 lines · Dirk Brandewie
Quoted 35 lines · Viresh Kumar
Quoted 25 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
There is an additional reference added to the driver in
cpufreq_add_dev()that is removedin__cpufreq_governor()if thedriver implements
target(). Remove the last reference when the driver implementssetpolicy()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/cpufreq/cpufreq.c +0
-0@@ -1049,6 +1049,9 @@ static int __cpufreq_remove_dev(struct device *dev,struct
subsys_interface*sifif (cpufreq_driver->target) __cpufreq_governor(data, CPUFREQ_GOV_STOP);drivers/cpufreq/cpufreq.c static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif · line 1053
Quoted 2 lines
drivers/cpufreq/cpufreq.c +2
-0+if (cpufreq_driver->setpolicy) +cpufreq_cpu_put (data);I don't understand this patch at all.. I grepped both
cpufreq_cpu_get()&put()
in bleeding-edge and found everything to be correct.
Quoted 4 lines
Quoted 2 lines
Can you please point me to the exact line numbers ?
Line 878 in
cpufreq_add_dev()
Following is line 878:
for_each_online_cpu(sibling) {
struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling);
if (cp && cpumask_test_cpu(cpu, cp->related_cpus))
return cpufreq_add_policy_cpu(cpu, sibling, dev);
}How is this related to your patch?
Re: [PATCH 5/7] cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
Quoted 44 lines · Viresh Kumar
Quoted 36 lines · Dirk Brandewie
Quoted 35 lines · Viresh Kumar
Quoted 25 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
There is an additional reference added to the driver in
cpufreq_add_dev()that is removedin__cpufreq_governor()if thedriver implements
target(). Remove the last reference when the driver implementssetpolicy()Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/cpufreq/cpufreq.c +0
-0@@ -1049,6 +1049,9 @@ static int __cpufreq_remove_dev(struct device *dev,struct
subsys_interface*sifif (cpufreq_driver->target) __cpufreq_governor(data, CPUFREQ_GOV_STOP);drivers/cpufreq/cpufreq.c static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif · line 1053
Quoted 2 lines
drivers/cpufreq/cpufreq.c +2
-0+if (cpufreq_driver->setpolicy) +cpufreq_cpu_put (data);I don't understand this patch at all.. I grepped both
cpufreq_cpu_get()&put()
in bleeding-edge and found everything to be correct.Quoted 4 lines
Quoted 2 lines
Can you please point me to the exact line numbers ?
Line 878 in
cpufreq_add_dev()Following is line 878:
Quoted 8 lines
for_each_online_cpu(sibling) { struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling); if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) return cpufreq_add_policy_cpu(cpu, sibling, dev); }How is this related to your patch?
our files are clearly out of sync :-) The code in cpufreq_add_dev() is
#ifdef CONFIG_SMP
/* check whether a different CPU already registered this
* CPU because it is in the same boat. */
policy = cpufreq_cpu_get(cpu);
if (unlikely(policy)) {
cpufreq_cpu_put(policy);
return 0;
}The reference added by this cpufreq_cpu_get() is finally dropped in __cpufreq_remove_dev() with the call to __cpufreq_governor()
if (driver->target) __cpufreq_governor(data, CPUFREQ_GOV_STOP);
Without this change I hang at:
pr_debug("waiting for dropping of refcount\n");
wait_for_completion(cmp);--Dirk
Viresh Kumar
maintainerRe: [PATCH 5/7] cpufreq: balance out cpufreq_cpu_{get,put} for scaling drivers using setpolicy
Quoted 1 line · Dirk Brandewie
our files are clearly out of sync :-) The code in
cpufreq_add_dev()is
I was at latest bleeding-edge then, but i still have below code in my HEAD.
Quoted 11 lines
#ifdef CONFIG_SMP /* check whether a different CPU already registered this * CPU because it is in the same boat. */ policy = cpufreq_cpu_get(cpu); if (unlikely(policy)) { cpufreq_cpu_put(policy); return 0; }The reference added by this
cpufreq_cpu_get()is finally dropped in__cpufreq_remove_dev()with the call to__cpufreq_governor()
__cpufreq_governor() is not calling cpufreq_cpu_put() at all and is dropping reference for the governor only, not for policy.
Quoted 6 lines
if (driver->target) __cpufreq_governor(data, CPUFREQ_GOV_STOP);Without this change I hang at:
pr_debug("waiting for dropping of refcount\n"); wait_for_completion(cmp);
Below should have fixed it for you i believe.
pr_debug("%s: removing link, cpu: %d\n", __func__, cpu);
cpufreq_cpu_put(data);
unlock_policy_rwsem_write(cpu);--
viresh
PATCH 6/7 cpufreq_stats: do not remove sysfs files if frequency table is not present
In reply to [email protected]From: Dirk Brandewie <[email protected]>
The sysfs files for cpufreq_stats are created in cpufreq_stats_create_table() called from cpufreq_stat_notifier_policy() when a policy is added to the cpu. cpufreq_stats_create_table() will not be called if the scaling driver does not export a frequency table to cpufreq. Use the same fence on tear down.
--- drivers/cpufreq/cpufreq_stats.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/cpufreq/cpufreq_stats.c +5 -0
@@ -185,6 +185,11 @@ static void cpufreq_stats_free_table(unsigned int cpu)static void cpufreq_stats_free_sysfs (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); +struct cpufreq_frequency_table *table; + + table =cpufreq_frequency_get_table (cpu); +if (!table) +return ;if (policy && !policy_is_shared (policy)) {pr_debug ("%s: Free sysfs stat\n" , __func__);sysfs_remove_group (&policy->kobj, &stats_attr_group);
Signature · 1 line
1.7.7.6
Viresh Kumar
maintainerRe: [PATCH 6/7] cpufreq_stats: do not remove sysfs files if frequency table is not present
Quoted 18 lines · On Tue, Feb 5, 2013 at 11:54 PM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
The sysfs files for
cpufreq_statsare created incpufreq_stats_create_table()called fromcpufreq_stat_notifier_policy()when a policy is added to the cpu.cpufreq_stats_create_table()will not be called if the scaling driver does not export a frequency table to cpufreq. Use the same fence on tear down.Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/cpufreq_stats.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)drivers/cpufreq/cpufreq_stats.c +0
-0
drivers/cpufreq/cpufreq_stats.c static void cpufreq_stats_free_table(unsigned int cpu) · line 192
Quoted 8 lines
drivers/cpufreq/cpufreq_stats.c +5
-0@@ -185,6 +185,11 @@ static void cpufreq_stats_free_table(unsigned int cpu)static void cpufreq_stats_free_sysfs (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); +struct cpufreq_frequency_table *table; + + table =cpufreq_frequency_get_table (cpu); +if (!table) +return ;
Because we aren't using table later on, i would write it as:
Quoted 2 lines
drivers/cpufreq/cpufreq_stats.c +2
-0+if (!cpufreq_frequency_get_table (cpu)) +return ;
PATCH 7/7 cpufreq/x86: Add P-state driver for sandy bridge.
In reply to [email protected]From: Dirk Brandewie <[email protected]>
Add a P-state driver for the Intel Sandy bridge processor. In cpufreq terminology this driver implements a scaling driver with an internal governor.
When built into the the kernel this driver will be the preferred scaling driver for Sandy bridge processors.
In addition to the interfaces provided by the cpufreq subsystem for controlling scaling drivers. The user may control the behavior of the driver via three sysfs files located in "/sys/devices/system/cpu/intel_pstate".
max_perf_pct: limits the maximum P state that will be requested by the driver stated as a percentage of the avail performance.
min_perf_pct: limits the minimum P state that will be requested by the driver stated as a percentage of the avail performance.
no_turbo: limits the driver to selecting P states below the turbo frequency range.
--- drivers/cpufreq/Kconfig.x86 | 18 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/intel_pstate.c | 829 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 848 insertions(+), 0 deletions(-) create mode 100644 drivers/cpufreq/intel_pstate.c
drivers/cpufreq/Kconfig.x86 +18 -0
@@ -2,6 +2,24 @@ # x86 CPU Frequency scaling drivers # +config X86_INTEL_PSTATE + tristate "Intel P state control" + depends on X86 + help + This driver provides a P state for Intel core processors. + The driver implements an internal governor and will become + the scaling driver and governor for Sandy bridge processors. + + When this driver is enabled it will become the perferred + scaling driver for Sandy bridge processors. + + Note: This driver should be built with the same settings as + the other scaling drivers configured into the system + (module/built-in) in order for the driver to register itself + as the scaling driver on the system. + + If in doubt, say N. + config X86_PCC_CPUFREQ tristate "Processor Clocking Control interface driver" depends on ACPI && ACPI_PROCESSOR
drivers/cpufreq/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_X86_SPEEDSTEP_SMI) += speedstep-smi.o obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o +obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o ################################################################################## # ARM SoC drivers
drivers/cpufreq/intel_pstate.c new file +829 -0
829 lines not on this page · raw message
Signature · 1 line
1.7.7.6