Skip to contentSkip to conversation

cpufreq_driver->resume

RFC In review Dominik Brodowski 2 participants 3 messages Sep 2, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 cpufreq_driver->resume

Documentation/cpu-freq/cpu-drivers.txt +6 -0
diff -ruN linux-original/Documentation/cpu-freq/cpu-drivers.txt linux/Documentation/cpu-freq/cpu-drivers.txt
@@ -64,6 +64,12 @@
 
 cpufreq_driver.exit -		A pointer to a per-CPU cleanup function.
 
+cpufreq_driver.resume -		A pointer to a per-CPU resume function
+				which is called with interrupts disabled
+				and _before_ the pre-suspend frequency
+				and/or policy is restored by a call to
+				->target or ->setpolicy.
+
 cpufreq_driver.attr -		A pointer to a NULL-terminated list of
 				"struct freq_attr" which allow to
 				export values to sysfs.
drivers/cpufreq/cpufreq.c +13 -0
diff -ruN linux-original/drivers/cpufreq/cpufreq.c linux/drivers/cpufreq/cpufreq.c
@@ -493,6 +493,13 @@
 	if (!cpu_policy)
 		return -EINVAL;
 
+	if (cpufreq_driver->resume)
+		ret = cpufreq_driver->resume(cpu_policy);
+	if (ret) {
+		printk(KERN_ERR "cpufreq: resume failed in ->resume step on CPU %u\n", cpu_policy->cpu);
+		goto out;
+	}
+
 	if (cpufreq_driver->setpolicy)
 		ret = cpufreq_driver->setpolicy(cpu_policy);
 	else
@@ -501,6 +508,12 @@
 	 */
 		ret = cpufreq_driver->target(cpu_policy, cpu_policy->cur, CPUFREQ_RELATION_H);
 
+	if (ret) {
+		printk(KERN_ERR "cpufreq: resume failed in ->setpolicy/target step on CPU %u\n", cpu_policy->cpu);
+		goto out;
+	}
+
+ out:
 	cpufreq_cpu_put(cpu_policy);
 
 	return ret;
include/linux/cpufreq.h +1 -0
diff -ruN linux-original/include/linux/cpufreq.h linux/include/linux/cpufreq.h
@@ -179,6 +179,7 @@
 
 	/* optional */
 	int	(*exit)		(struct cpufreq_policy *policy);
+	int	(*resume)	(struct cpufreq_policy *policy);
 	struct freq_attr	**attr;
 };
#1 lore raw

Documentation/cpu-freq/cpu-drivers.txt line 72

Quoted 6 lines · Dominik Brodowski
Documentation/cpu-freq/cpu-drivers.txt +6 -0
+cpufreq_driver.resume -		A pointer to a per-CPU resume function
+				which is called with interrupts disabled
+				and _before_ the pre-suspend frequency
+				and/or policy is restored by a call to
+				->target or ->setpolicy.
+

What advantage is there to doing things this way over just setting the speed to the last known value before we suspended ? (though some drivers may need fixing, as they shortcut the
'trying to set to current speed' thing with a return so we don't actually poke anything.)

Dave

Signature · 1 line
 Dave Jones     http://www.codemonkey.org.uk
#2 lore raw
Quoted 15 lines · Dave Jones

Documentation/cpu-freq/cpu-drivers.txt line 72

Quoted 6 lines · Dominik Brodowski
Documentation/cpu-freq/cpu-drivers.txt +6 -0
+cpufreq_driver.resume -		A pointer to a per-CPU resume function
+				which is called with interrupts disabled
+				and _before_ the pre-suspend frequency
+				and/or policy is restored by a call to
+				->target or ->setpolicy.
+

What advantage is there to doing things this way over just setting the speed to the last known value before we suspended ? (though some drivers may need fixing, as they shortcut the
'trying to set to current speed' thing with a return so we don't actually poke anything.)

Check the speedstep_smi driver -- it needs to pass a value to the BIOS after every resume sequence. It was done there using a pm_dev, the generic/new ->resume callback seems to be better suited for this.

Dominik