Skip to contentSkip to conversation

Longhaul - Test

PATCH New Rafał Bilski 1 participant 1 message Jul 13, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Longhaul - Test

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

---

arch/i386/kernel/cpu/cpufreq/longhaul.c +30 -0
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
@@ -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