All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Longhaul - Test
@ 2006-07-13 18:57 Rafał Bilski
  0 siblings, 0 replies; only message in thread
From: Rafał Bilski @ 2006-07-13 18:57 UTC (permalink / raw)
  To: Dave Jones; +Cc: cpufreq

Test checking if ACPI C3 is really working in user computer.

Signed-off-by: Rafa³ Bilski <rafalbilski@interia.pl>

---

diff -uprN -X linux-2.6.17-git20-vanilla/Documentation/dontdiff linux-2.6.17-git20-vanilla/arch/i386/kernel/cpu/cpufreq/longhaul.c linux-2.6.17-git20/arch/i386/kernel/cpu/cpufreq/longhaul.c
--- linux-2.6.17-git20-vanilla/arch/i386/kernel/cpu/cpufreq/longhaul.c	2006-07-13 07:39:41.000000000 +0200
+++ linux-2.6.17-git20/arch/i386/kernel/cpu/cpufreq/longhaul.c	2006-07-13 20:36:22.000000000 +0200
@@ -543,6 +543,7 @@ static int __init longhaul_cpu_init(stru
 	struct cpuinfo_x86 *c = cpu_data;
 	char *cpuname=NULL;
 	int ret;
+	unsigned int i, min, min_index, max, max_index;
 
 	/* Check ACPI support for C3 state */
 	acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
@@ -642,6 +643,30 @@ static int __init longhaul_cpu_init(stru
 		 (dont_scale_voltage==0))
 		longhaul_setup_voltagescaling();
 
+	/* Check if longhaul really works */
+	/* Find min and max frequencies */
+	i = max = max_index = min_index = 0;
+	min = ~0;
+	while (longhaul_table[i].frequency != CPUFREQ_TABLE_END) {
+		if (longhaul_table[i].frequency < min) {
+			min = longhaul_table[i].frequency;
+			min_index = longhaul_table[i].index;
+		} else if (longhaul_table[i].frequency > max) {
+			max = longhaul_table[i].frequency;
+			max_index = longhaul_table[i].index;
+		}
+		i++;
+	}
+	/* Change to min */
+	longhaul_setstate(min_index);
+	/* Check */
+	if ( calc_speed(longhaul_get_cpu_mult()) != min ) goto err_test;
+	/* Change to max */
+	longhaul_setstate(max_index);
+	/* Check */
+	if ( calc_speed(longhaul_get_cpu_mult()) != max ) goto err_test;
+
+	/* Seems to be working. Add longhaul driver to cpufreq core */
 	policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
 	policy->cpuinfo.transition_latency = 200000;	/* nsec */
 	policy->cur = calc_speed(longhaul_get_cpu_mult());
@@ -657,6 +682,11 @@ static int __init longhaul_cpu_init(stru
 err_acpi:
 	printk(KERN_ERR PFX "No ACPI support for CPU frequency changes.\n");
 	return -ENODEV;
+
+err_test:
+	printk(KERN_ERR PFX "Test failed. Aborting.\n");
+	kfree(longhaul_table);
+	return -ENODEV;
 }
 
 static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)

----------------------------------------------------------------------
Upal jakby mniejszy... http://link.interia.pl/f1975

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-07-13 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-13 18:57 [PATCH] Longhaul - Test Rafał Bilski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.