]> git.hungrycats.org Git - linux/commitdiff
[CPUFREQ] Add p4-clockmod ->get
authorDave Jones <davej@redhat.com>
Fri, 7 May 2004 16:32:21 +0000 (17:32 +0100)
committerDave Jones <davej@delerium.codemonkey.org.uk>
Fri, 7 May 2004 16:32:21 +0000 (17:32 +0100)
p4-clockmod is a bit more complicated as it might run on SMP, HT, and
the instructions need to run on the specific (physical) CPU.

arch/i386/kernel/cpu/cpufreq/p4-clockmod.c

index 28d5e2243017a658489510db5346909e88fbc9f3..a9be690b461119f451ddf57d3a698d8ad3711c31 100644 (file)
@@ -252,6 +252,43 @@ static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)
        return 0;
 }
 
+static unsigned int cpufreq_p4_get(unsigned int cpu)
+{
+       unsigned int hyperthreading;
+       cpumask_t cpus_allowed, affected_cpu_map;
+       u32 l, h;
+
+       hyperthreading = 0;
+
+       /* only run on CPU to be set, or on its sibling */
+       cpus_allowed = current->cpus_allowed;
+       affected_cpu_map = cpumask_of_cpu(cpu);
+#ifdef CONFIG_X86_HT
+       hyperthreading = ((cpu_has_ht) && (smp_num_siblings == 2));
+       if (hyperthreading) {
+               sibling = cpu_sibling_map[cpu];
+               cpu_set(sibling, affected_cpu_map);
+       }
+#endif
+       set_cpus_allowed(current, affected_cpu_map);
+        BUG_ON(!cpu_isset(smp_processor_id(), affected_cpu_map));
+
+       rdmsr(MSR_IA32_THERM_CONTROL, l, h);
+
+       set_cpus_allowed(current, cpus_allowed);
+
+       if (l & 0x10) {
+               l = l >> 1;
+               l &= 0x7;
+       } else
+               l = DC_DISABLE;
+
+       if (l != DC_DISABLE)
+               return (stock_freq * l / 8);
+
+       return stock_freq;
+}
+
 static struct freq_attr* p4clockmod_attr[] = {
        &cpufreq_freq_attr_scaling_available_freqs,
        NULL,
@@ -262,6 +299,7 @@ static struct cpufreq_driver p4clockmod_driver = {
        .target         = cpufreq_p4_target,
        .init           = cpufreq_p4_cpu_init,
        .exit           = cpufreq_p4_cpu_exit,
+       .get            = cpufreq_p4_get,
        .name           = "p4-clockmod",
        .owner          = THIS_MODULE,
        .attr           = p4clockmod_attr,