Skip to contentSkip to conversation

cpufreq: Processor Clocking Control interface driver

PATCH Superseded Naga Chumbalkar 2 participants 6 messages Dec 11, 2009 – Dec 16, 2009

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: Processor Clocking Control interface driver

Processor Clocking Control (PCC) is an interface between the BIOS and OSPM. Based on the server workload, OSPM can request what frequency it expects from a logical CPU, and the BIOS will achieve that frequency transparently.

This patch introduces driver support for PCC. OSPM uses the PCC driver to communicate with the BIOS via the PCC interface.

Currently, certain HP ProLiant platforms implement the PCC interface. However, any platform whose BIOS implements the PCC Specification, can utilize this driver.

There is a Documentation file that provides a link to the PCC Specification, and also provides a summary of the PCC interface.

Caveat:
Currently, the "cpufreq_stats" module in its present form cannot be loaded and expected to work with the PCC driver. A patch to cpufreq_stats will be submitted to fix this.

---
 Documentation/cpu-freq/pcc-cpufreq.txt    |  209 +++++++++
 arch/x86/kernel/cpu/cpufreq/Kconfig       |   15 +
 arch/x86/kernel/cpu/cpufreq/Makefile      |    1 +
 arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c |  649 +++++++++++++++++++++++++++++
 drivers/acpi/processor_core.c             |    2 +
 5 files changed, 876 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/cpu-freq/pcc-cpufreq.txt
 create mode 100644 arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c
Documentation/cpu-freq/pcc-cpufreq.txt new file +209 -0
new file mode 100644
index 0000000..656db96
@@ -0,0 +1,209 @@
+/*
+ *  pcc-cpufreq.txt - PCC interface documentation
+ *
+ *  Copyright (C) 2009 Red Hat, Matthew Garrett <[email protected]>
+ *  Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
+ *      Nagananda Chumbalkar <[email protected]>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or NON
+ *  INFRINGEMENT. See the GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+			Processor Clocking Control Driver
+			---------------------------------
+
+Contents:
+---------
+1.	Introduction
+1.1	PCC interface
+1.1.1   Get Average Frequency
+1.1.2	Set Desired Frequency
+1.2	Platforms affected
+2.	Driver and /sys details
+2.1	scaling_available_frequencies
+2.2	cpuinfo_transition_latency
+2.3	cpuinfo_cur_freq
+2.4	related_cpus
+3.	Caveats
+
+1. Introduction:
+----------------
+Processor Clocking Control (PCC) is an interface between the platform
+firmware and OSPM. It is a mechanism for coordinating processor
+performance (ie: frequency) between the platform firmware and the OS.
+
+The PCC driver (pcc-cpufreq) allows OSPM to take advantage of the PCC
+interface.
+
+OS utilizes the PCC interface to inform platform firmware what frequency the
+OS wants for a logical processor. The platform firmware attempts to achieve
+the requested frequency. If the request for the target frequency could not be
+satisfied by platform firmware, then it usually means that power budget
+conditions are in place, and "power capping" is taking place.
+
+1.1 PCC interface:
+------------------
+The complete PCC specification is available here:
+http://www.acpica.org/download/Processor-Clocking-Control-v1p0.pdf
+
+PCC relies on a shared memory region that provides a channel for communication
+between the OS and platform firmware. PCC also implements a "doorbell" that
+is used by the OS to inform the platform firmware that a command has been
+sent.
+
+The ACPI PCCH() method is used to discover the location of the PCC shared
+memory region. The shared memory region header contains the "command" and
+"status" interface. PCCH() also contains details on how to access the platform
+doorbell.
+
+The following commands are supported by the PCC interface:
+* Get Average Frequency
+* Set Desired Frequency
+
+The ACPI PCCP() method is implemented for each logical processor and is
+used to discover the offsets for the input and output buffers in the shared
+memory region.
+
+When PCC mode is enabled, the platform will not expose processor performance
+or throttle states (_PSS, _TSS and related ACPI objects) to OSPM. Therefore,
+the native P-state driver (such as acpi-cpufreq for Intel, powernow-k8 for
+AMD) will not load.
+
+However, OSPM remains in control of policy. The governor (eg: "ondemand")
+computes the required performance for each processor based on server workload.
+The PCC driver fills in the command interface, and the input buffer and
+communicates the request to the platform firmware. The platform firmware is
+responsible for delivering the requested performance.
+
+Each PCC command is "global" in scope and can affect all the logical CPUs in
+the system. Therefore, PCC is capable of performing "group" updates. With PCC
+the OS is capable of getting/setting the frequency of all the logical CPUs in
+the system with a single call to the BIOS.
+
+1.1.1 Get Average Frequency:
+----------------------------
+This command is used by the OSPM to query the running frequency of the
+processor since the last time this command was completed. The output buffer
+indicates the average unhalted frequency of the logical processor expressed as
+a percentage of the nominal (ie: maximum) CPU frequency. The output buffer
+also signifies if the CPU frequency is limited by a power budget condition.
+
+1.1.2 Set Desired Frequency:
+----------------------------
+This command is used by the OSPM to communicate to the platform firmware the
+desired frequency for a logical processor. The output buffer is currently
+ignored by OSPM. The next invocation of "Get Average Frequency" will inform
+OSPM if the desired frequency was achieved or not.
+
+1.2 Platforms affected:
+-----------------------
+The PCC driver will load on any system where the platform firmware:
+* supports the PCC interface, and the associated PCCH() and PCCP() methods
+* assumes responsibility for managing the hardware clocking controls in order
+to deliver the requested processor performance
+
+Currently, certain HP ProLiant platforms implement the PCC interface. On those
+platforms PCC is the "default" choice.
+
+However, it is possible to disable this interface via a BIOS setting. In
+such an instance, as is also the case on platforms where the PCC interface
+is not implemented, the PCC driver will fail to load silently.
+
+2. Driver and /sys details:
+---------------------------
+When the driver loads, it merely prints the lowest and the highest CPU
+frequencies supported by the platform firmware.
+
+The PCC driver loads with a message such as:
+pcc-cpufreq: (v1.00.00) driver loaded with frequency limits: 1600 MHz, 2933
+MHz
+
+This means that the OPSM can request the CPU to run at any frequency in
+between the limits (1600 MHz, and 2933 MHz) specified in the message.
+
+Internally, there is no need for the driver to convert the "target" frequency
+to a corresponding P-state.
+
+The VERSION number for the driver will be of the format v.xy.ab.
+eg: 1.00.02
+   ----- --
+    |    |
+    |    -- this will increase with bug fixes/enhancements to the driver
+    |-- this is the version of the PCC specification the driver adheres to
+
+
+The following is a brief discussion on some of the fields exported via the
+/sys filesystem and how their values are affected by the PCC driver:
+
+2.1 scaling_available_frequencies:
+----------------------------------
+scaling_available_frequencies indicates the minimum and maximum speed
+the CPU can take as advertised by the BIOS. No intermediate frequencies are
+listed because the BIOS will try to achieve any intermediate frequency
+requested by the governor. An intermediate frequency does not have to be
+strictly associated with a P-state.
+
+2.2 cpuinfo_transition_latency:
+-------------------------------
+The cpuinfo_transition_latency field is 0. The PCC specification does
+not include a field to expose this value currently.
+
+2.3 cpuinfo_cur_freq:
+---------------------
+A) Often cpuinfo_cur_freq will show a value different than what is declared
+in the scaling_available_frequencies or scaling_cur_freq, or scaling_max_freq.
+This is due to "turbo boost" available on recent Intel processors. If certain
+conditions are met the BIOS can achieve a slightly higher speed than requested
+by OSPM. An example:
+
+scaling_cur_freq	: 2933000
+cpuinfo_cur_freq	: 3196000
+
+B) There is a round-off error associated with the cpuinfo_cur_freq value.
+Since the driver obtains the current frequency as a "percentage" (%) of the
+nominal frequency from the BIOS, sometimes, the values displayed by
+scaling_cur_freq and cpuinfo_cur_freq may not match. An example:
+
+scaling_cur_freq	: 1600000
+cpuinfo_cur_freq	: 1583000
+
+In this example, the nominal frequency is 2933 MHz. The driver obtains the
+current frequency, cpuinfo_cur_freq, as 54% of the nominal frequency:
+
+	54% of 2933 MHz = 1583 MHz
+
+Nominal frequency is the maximum frequency of the processor, and it usually
+corresponds to the frequency of the P0 P-state.
+
+2.4 related_cpus:
+-----------------
+The related_cpus field is identical to affected_cpus.
+
+affected_cpus	: 4
+related_cpus	: 4
+
+Currently, the PCC driver does not evaluate _PSD. The platforms that support
+PCC do not implement SW_ALL. So OSPM doesn't need to perform any coordination
+to ensure that the same frequency is requested of all dependent CPUs.
+
+3. Caveats:
+-----------
+Currently, the "cpufreq_stats" module in its present form cannot be loaded and
+expected to work with the PCC driver. A patch to cpufreq_stats will be
+submitted to fix this.
+
arch/x86/kernel/cpu/cpufreq/Kconfig +15 -0
index f138c6c..d5cefae 100644
@@ -10,6 +10,21 @@ if CPU_FREQ
 
 comment "CPUFreq processor drivers"
 
+config X86_PCC_CPUFREQ
+	tristate "Processor Clocking Control interface driver"
+	select CPU_FREQ_TABLE
+	depends on ACPI && ACPI_PROCESSOR
+	help
+	  This driver adds support for the PCC interface.
+
+	  For details, take a look at:
+	  <file:Documentation/cpu-freq/pcc-cpufreq.txt>.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pcc-cpufreq.
+
+	  If in doubt, say N.
+
 config X86_ACPI_CPUFREQ
 	tristate "ACPI Processor P-States driver"
 	select CPU_FREQ_TABLE
arch/x86/kernel/cpu/cpufreq/Makefile +1 -0
index 509296d..1840c0a 100644
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_X86_POWERNOW_K8)		+= powernow-k8.o
 obj-$(CONFIG_X86_ACPI_CPUFREQ)		+= acpi-cpufreq.o
+obj-$(CONFIG_X86_PCC_CPUFREQ)		+= pcc-cpufreq.o
 obj-$(CONFIG_X86_POWERNOW_K6)		+= powernow-k6.o
 obj-$(CONFIG_X86_POWERNOW_K7)		+= powernow-k7.o
 obj-$(CONFIG_X86_LONGHAUL)		+= longhaul.o
arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c new file +649 -0

649 lines not on this page · raw message

drivers/acpi/processor_core.c +2 -0
index cb4283f..9dcf207 100644
@@ -123,6 +123,8 @@ static const struct file_operations acpi_processor_info_fops = {
 #endif
 
 DEFINE_PER_CPU(struct acpi_processor *, processors);
+EXPORT_PER_CPU_SYMBOL(processors);
+
 struct acpi_processor_errata errata __read_mostly;
 static int set_no_mwait(const struct dmi_system_id *id)
 {
Signature · 1 line
1.6.2.2
#1 lore raw

Hey,

Documentation/cpu-freq/pcc-cpufreq.txt line 147

Quoted 6 lines · Naga Chumbalkar
Documentation/cpu-freq/pcc-cpufreq.txt new file +6 -0
+The VERSION number for the driver will be of the format v.xy.ab.
+eg: 1.00.02
+   ----- --
+    |    |
+    |    -- this will increase with bug fixes/enhancements to the driver
+    |-- this is the version of the PCC specification the driver adheres to

If this is _really_ necessary... Doesn't the driver version relate to some Linux kernel version anyway?

Documentation/cpu-freq/pcc-cpufreq.txt line 159

Quoted 7 lines

+2.1 scaling_available_frequencies:
+----------------------------------

Documentation/cpu-freq/pcc-cpufreq.txt new file +5 -0
+scaling_available_frequencies indicates the minimum and maximum speed
+the CPU can take as advertised by the BIOS. No intermediate frequencies are
+listed because the BIOS will try to achieve any intermediate frequency
+requested by the governor. An intermediate frequency does not have to be
+strictly associated with a P-state.

Why do you export scaling_available_frequencies anyway? It's made available by the _optional_ freq-table helper module, which is wrong to use in this case anyway.

Documentation/cpu-freq/pcc-cpufreq.txt line 164

Quoted 4 lines

+2.2 cpuinfo_transition_latency:
+-------------------------------

Documentation/cpu-freq/pcc-cpufreq.txt new file +2 -0
+The cpuinfo_transition_latency field is 0. The PCC specification does
+not include a field to expose this value currently.

Uh, bad specification... So does it work properly with ondemand and/or conservative (which read out this field, and if latency=0 use a minimum value)?

arch/x86/kernel/cpu/cpufreq/Kconfig if CPU_FREQ · line 15

Quoted 3 lines
arch/x86/kernel/cpu/cpufreq/Kconfig +3 -0
+config X86_PCC_CPUFREQ
+	tristate "Processor Clocking Control interface driver"
+	select CPU_FREQ_TABLE

Uh, see above.

arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c line 123

Quoted 4 lines
arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c new file +4 -0
+static int pcc_cpufreq_verify(struct cpufreq_policy *policy)
+{
+	return cpufreq_frequency_table_verify(policy, pcc_freq_table);
+}

Well, AFAICS, this limits the whole interface to two values: min or max. So let's allow for any intermediate value:

static int pcc_cpufreq_verify(struct cpufreq_policy *policy)

{
	cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
}

but well... later on, you check this:

arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c line 223

Quoted 5 lines
arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c new file +5 -0
+	if (target_freq <= (ioread32(&pcch_hdr->minimum_frequency) * 1000)) {
+		target_freq = ioread32(&pcch_hdr->minimum_frequency) * 1000;
+		dprintk("target: target_freq for cpu %d was below limit, "
+			"converted it to %d\n", cpu, target_freq);
+	}

why not do this in the _verify() step? Does pcch_hdr->minimum_frequency even change "on the fly"?

So, I'd propose to NACK this patch at the moment.

Best,
Dominik

#2 lore raw

Hi, I have addressed your concerns below:

Quoted 19 lines

-----Original Message-----
From: Dominik Brodowski [mailto:[email protected]]
Sent: Friday, December 11, 2009 5:13 PM
To: Chumbalkar, Nagananda
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] cpufreq: Processor Clocking Control interface driver

Hey,

Review

Quoted 5 lines · Naga Chumbalkar
(quoted diff) +5 -0
+The VERSION number for the driver will be of the format v.xy.ab.
+eg: 1.00.02
+   ----- --
+    |    |
+    |    -- this will increase with bug fixes/enhancements 

to the driver

Quoted 7 lines
Quoted 1 line

+ |-- this is the version of the PCC specification the

driver adheres to

If this is _really_ necessary... Doesn't the driver version relate to some
Linux kernel version anyway?

If distros backport this driver to different kernel versions, it will be easy to keep track of which driver version is in the distro.

Quoted 9 lines
Quoted 3 lines

+2.1 scaling_available_frequencies:
+----------------------------------
+scaling_available_frequencies indicates the minimum and

maximum speed

Quoted 1 line

+the CPU can take as advertised by the BIOS. No intermediate

frequencies are

Quoted 1 line

+listed because the BIOS will try to achieve any

intermediate frequency

Quoted 1 line

+requested by the governor. An intermediate frequency does

Quoted 9 lines

not have to be

Quoted 1 line

+strictly associated with a P-state.

Why do you export scaling_available_frequencies anyway? It's made available
by the _optional_ freq-table helper module, which is wrong to use in this
case anyway.

You are correct. I don't need the dependency on CPU_FREQ_TABLE. I ripped it out and made suitable changes:

pcc-cpufreq.c +3 -24
diff -bur orig/pcc-cpufreq.c fix/pcc-cpufreq.c
@@ -111,15 +111,11 @@
 
 static struct pcc_cpu *pcc_cpu_info;
 
-static struct cpufreq_frequency_table pcc_freq_table[] = {
-	{0x1, 0},
-	{0x2, 0},
-	{0, CPUFREQ_TABLE_END},
-};
-
 static int pcc_cpufreq_verify(struct cpufreq_policy *policy)
 {
-	return cpufreq_frequency_table_verify(policy, pcc_freq_table);
+	cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
+				     policy->cpuinfo.max_freq);
+	return 0;
 }
 
 static inline void pcc_cmd(void)
@@ -534,10 +530,6 @@
 		goto pcch_free;
 	}
 
-	pcc_freq_table[0].frequency =
-		ioread32(&pcch_hdr->minimum_frequency) * 1000;
-	pcc_freq_table[1].frequency = ioread32(&pcch_hdr->nominal) * 1000;
-
 	printk(KERN_DEBUG "pcc-cpufreq: (v%s) driver loaded with frequency"
 	       " limits: %d MHz, %d MHz\n", PCC_VERSION,
 	       ioread32(&pcch_hdr->minimum_frequency),
@@ -576,12 +568,6 @@
 	dprintk("init: policy->max is %d, policy->min is %d\n",
 		policy->max, policy->min);
 
-	result = cpufreq_frequency_table_cpuinfo(policy, pcc_freq_table);
-	if (result)
-		goto free;
-
-	cpufreq_frequency_table_get_attr(pcc_freq_table, policy->cpu);
-
 	return 0;
 free:
 	pcc_clear_mapping();
@@ -592,15 +578,9 @@
 
 static int pcc_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 {
-	cpufreq_frequency_table_put_attr(policy->cpu);
 	return 0;
 }
 
-static struct freq_attr *pcc_cpufreq_attr[] = {
-	&cpufreq_freq_attr_scaling_available_freqs,
-	NULL,
-};
-
 static struct cpufreq_driver pcc_cpufreq_driver = {
 	.flags = CPUFREQ_CONST_LOOPS,
 	.get = pcc_get_freq,
@@ -610,7 +590,6 @@
 	.exit = pcc_cpufreq_cpu_exit,
 	.name = "pcc-cpufreq",
 	.owner = THIS_MODULE,
-	.attr = pcc_cpufreq_attr,
 };
 
 static int __init pcc_cpufreq_init(void)
pcc-cpufreq.txt +7 -8
diff -bur orig/pcc-cpufreq.txt fix/pcc-cpufreq.txt
@@ -152,11 +152,10 @@
 
 2.1 scaling_available_frequencies:
 ----------------------------------
-scaling_available_frequencies indicates the minimum and maximum speed
-the CPU can take as advertised by the BIOS. No intermediate frequencies are
-listed because the BIOS will try to achieve any intermediate frequency
-requested by the governor. An intermediate frequency does not have to be
-strictly associated with a P-state.
+scaling_available_frequencies is not created in /sys. No intermediate
+frequencies need to be listed because the BIOS will try to achieve any
+frequency, within limits, requested by the governor. A frequency does not have
+to be strictly associated with a P-state.
 
 2.2 cpuinfo_transition_latency:
 -------------------------------
@@ -203,7 +202,7 @@
 
 3. Caveats:
 -----------
-Currently, the "cpufreq_stats" module in its present form cannot be loaded and
-expected to work with the PCC driver. A patch to cpufreq_stats will be
-submitted to fix this.
+The "cpufreq_stats" module in its present form cannot be loaded and
+expected to work with the PCC driver. Since the "cpufreq_stats" module
+provides information wrt each P-state, it is not applicable to the PCC driver.
 
Quoted 10 lines
Quoted 3 lines

+2.2 cpuinfo_transition_latency:
+-------------------------------
+The cpuinfo_transition_latency field is 0. The PCC

specification does

Quoted 1 line

+not include a field to expose this value currently.

Uh, bad specification... So does it work properly with ondemand and/or conservative (which read out this field, and if latency=0 use a minimum value)?

Yes, it works fine. Both "ondemand" and "conservative" sanitize the latency value, and set it to a default value which is good.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+config X86_PCC_CPUFREQ
+	tristate "Processor Clocking Control interface driver"
+	select CPU_FREQ_TABLE

Uh, see above.

Kconfig +0 -1
diff -bur orig/Kconfig fix/Kconfig
@@ -12,7 +12,6 @@
 
 config X86_PCC_CPUFREQ
 	tristate "Processor Clocking Control interface driver"
-	select CPU_FREQ_TABLE
 	depends on ACPI && ACPI_PROCESSOR
 	help
 	  This driver adds support for the PCC interface.
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+static int pcc_cpufreq_verify(struct cpufreq_policy *policy)
+{
+	return cpufreq_frequency_table_verify(policy, pcc_freq_table);
+}

Well, AFAICS, this limits the whole interface to two values:
min or max. So
let's allow for any intermediate value:

Quoted 6 lines

static int pcc_cpufreq_verify(struct cpufreq_policy *policy) {
cpufreq_verify_within_limits(policy,
policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); }

Took this suggestion, (see the first "diff" changeset above), especially since I cannot use the freq-table helper function anymore.

Quoted 6 lines

but well... later on, you check this

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (target_freq <= 

(ioread32(&pcch_hdr->minimum_frequency) * 1000)) {

Review

Quoted 1 line
(quoted diff) +1 -0
+		target_freq = 

ioread32(&pcch_hdr->minimum_frequency) * 1000;

Quoted 7 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		dprintk("target: target_freq for cpu %d was 

below limit, "

Review

Quoted 2 lines
(quoted diff) +2 -0
+			"converted it to %d\n", cpu, target_freq);
+	}

why not do this in the _verify() step? Does pcch_hdr->minimum_frequency even change "on the fly"?

pcch_hdr->minimum_frequency does not change "on the fly". Also, there is no need for those IO accesses:

pcc-cpufreq.c +8 -2
diff -bur orig/pcc-cpufreq.c fix/pcc-cpufreq.c
@@ -212,12 +212,18 @@
 
 	pcc_cpu_data = per_cpu_ptr(pcc_cpu_info, cpu);
 
-	if (target_freq <= (ioread32(&pcch_hdr->minimum_frequency) * 1000)) {
-		target_freq = ioread32(&pcch_hdr->minimum_frequency) * 1000;
+	if (target_freq < policy->min) {
+		target_freq = policy->min;
 		dprintk("target: target_freq for cpu %d was below limit, "
 			"converted it to %d\n", cpu, target_freq);
 	}
 
+	if (target_freq > policy->max) {
+		target_freq = policy->max;
+		dprintk("target: target_freq for cpu %d was above limit, "
+			"converted it to %d\n", cpu, target_freq);
+	}
+
 	dprintk("target: CPU %d should go to target freq: %d "
 		"(virtual) input_offset is 0x%x\n",
 		cpu, target_freq,
Quoted 6 lines

So, I'd propose to NACK this patch at the moment.

Best,
Dominik

If you are okay with the changes, I will send v2 of the patch.

Thanks,
- naga -

#3 lore raw

Hey,

Quoted 1 line · Nagananda

Hi, I have addressed your concerns below:

Thanks!

Quoted 7 lines
Quoted 4 lines

If this is _really_ necessary... Doesn't the driver version relate to some
Linux kernel version anyway?

If distros backport this driver to different kernel versions, it will be easy to keep track of which driver version is in the distro.

Well, IMVHO it's ugly, but if Linux ACPI and cpufreq folks are fine with it, so be it.

Quoted 2 lines

Yes, it works fine. Both "ondemand" and "conservative" sanitize the latency value, and set it to a default value which is good.

OK. Any way to fix the spec for the next revision, though?

Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (target_freq <= 

(ioread32(&pcch_hdr->minimum_frequency) * 1000)) {

Review

Quoted 1 line
(quoted diff) +1 -0
+		target_freq = 

ioread32(&pcch_hdr->minimum_frequency) * 1000;

Review

Quoted 1 line
(quoted diff) +1 -0
+		dprintk("target: target_freq for cpu %d was 

below limit, "

Quoted 8 lines
Quoted 5 lines

pcc-cpufreq.c line 225

Quoted 2 lines
pcc-cpufreq.c +2 -0
+			"converted it to %d\n", cpu, target_freq);
+	}

why not do this in the _verify() step? Does pcch_hdr->minimum_frequency even change "on the fly"?

pcch_hdr->minimum_frequency does not change "on the fly". Also, there is no need for those IO accesses:

target_freq cannot be below policy->min or above policy->max. If it were, the whole cpufreq subsystem is broken. So there's no need for these checks, AFAICS.

Best,
Dominik

#4 lore raw
Quoted 15 lines
Quoted 11 lines
Quoted 11 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+	if (target_freq <= 

(ioread32(&pcch_hdr->minimum_frequency) * 1000)) {

Review

Quoted 1 line
(quoted diff) +1 -0
+		target_freq = 

ioread32(&pcch_hdr->minimum_frequency) * 1000;

Review

Quoted 1 line
(quoted diff) +1 -0
+		dprintk("target: target_freq for cpu %d was 

below limit, "

pcc-cpufreq.c line 225

Quoted 2 lines
pcc-cpufreq.c +2 -0
+			"converted it to %d\n", cpu, target_freq);
+	}

why not do this in the _verify() step? Does

pcch_hdr->minimum_frequency

Quoted 3 lines
Quoted 1 line

even change "on the fly"?

pcch_hdr->minimum_frequency does not change "on the fly".

Quoted 9 lines

Also, there is no

Quoted 1 line

need for those IO accesses:

target_freq cannot be below policy->min or above policy->max. If it were,
the whole cpufreq subsystem is broken. So there's no need for these checks,
AFAICS.

I think the "ondemand" governor can ask for a target frequency that is below policy->min.

Let's say that at a given snapshot, the frequency of a CPU is policy->cur. At the next sampling, if the "load" on the CPU drops to a level that satisifies the equation below, then freq_next requested by "ondemand" will be below policy->min:

	load < (threshold - differential) * policy->min / policy->cur

A patch such as below may be needed to sanitize the target frequency requested by "ondemand". The "conservative" governor already has this check:

# diff -bur ./drivers/cpufreq/cpufreq_ondemand.c.orig ./drivers/cpufreq/cpufreq_ondemand.c
--- ./drivers/cpufreq/cpufreq_ondemand.c.orig   2009-12-11 15:06:02.000000000 -0600
+++ ./drivers/cpufreq/cpufreq_ondemand.c        2009-12-15 20:27:57.000000000 -0600
@@ -554,6 +554,9 @@
                                (dbs_tuners_ins.up_threshold -
                                 dbs_tuners_ins.down_differential);

+ if (freq_next < policy->min)
+ freq_next = policy->min;
+

                if (!dbs_tuners_ins.powersave_bias) {
                        __cpufreq_driver_target(policy, freq_next,
                                        CPUFREQ_RELATION_L);

- naga -

#5 lore raw

Hey,

Quoted 32 lines · Nagananda
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (target_freq <= 

(ioread32(&pcch_hdr->minimum_frequency) * 1000)) {

Review

Quoted 1 line
(quoted diff) +1 -0
+		target_freq = 

ioread32(&pcch_hdr->minimum_frequency) * 1000;

Review

Quoted 1 line
(quoted diff) +1 -0
+		dprintk("target: target_freq for cpu %d was 

below limit, "

pcc-cpufreq.c line 225

Quoted 2 lines
pcc-cpufreq.c +2 -0
+			"converted it to %d\n", cpu, target_freq);
+	}

why not do this in the _verify() step? Does

pcch_hdr->minimum_frequency

Quoted 3 lines
Quoted 1 line

even change "on the fly"?

pcch_hdr->minimum_frequency does not change "on the fly".

Quoted 9 lines

Also, there is no

Quoted 1 line

need for those IO accesses:

target_freq cannot be below policy->min or above policy->max. If it were,
the whole cpufreq subsystem is broken. So there's no need for these checks,
AFAICS.

I think the "ondemand" governor can ask for a target frequency that is below policy->min.

Let's say that at a given snapshot, the frequency of a CPU is policy->cur. At the next sampling, if the "load" on the CPU drops to a level that satisifies the equation below, then freq_next requested by "ondemand" will be below policy->min:

Quoted 4 lines
	load < (threshold - differential) * policy->min / policy->cur

A patch such as below may be needed to sanitize the target frequency requested by "ondemand". The "conservative" governor already has this check:

If freq_next < policy->min is indeed possible in ondemand, that's a real bug in ondemand.

Best,
Dominik