ia64/linux-2.6.18-xen.hg

annotate drivers/macintosh/windfarm_cpufreq_clamp.c @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
rev   line source
ian@0 1 #include <linux/types.h>
ian@0 2 #include <linux/errno.h>
ian@0 3 #include <linux/kernel.h>
ian@0 4 #include <linux/delay.h>
ian@0 5 #include <linux/slab.h>
ian@0 6 #include <linux/init.h>
ian@0 7 #include <linux/wait.h>
ian@0 8 #include <linux/cpufreq.h>
ian@0 9
ian@0 10 #include <asm/prom.h>
ian@0 11
ian@0 12 #include "windfarm.h"
ian@0 13
ian@0 14 #define VERSION "0.3"
ian@0 15
ian@0 16 static int clamped;
ian@0 17 static struct wf_control *clamp_control;
ian@0 18
ian@0 19 static int clamp_notifier_call(struct notifier_block *self,
ian@0 20 unsigned long event, void *data)
ian@0 21 {
ian@0 22 struct cpufreq_policy *p = data;
ian@0 23 unsigned long max_freq;
ian@0 24
ian@0 25 if (event != CPUFREQ_ADJUST)
ian@0 26 return 0;
ian@0 27
ian@0 28 max_freq = clamped ? (p->cpuinfo.min_freq) : (p->cpuinfo.max_freq);
ian@0 29 cpufreq_verify_within_limits(p, 0, max_freq);
ian@0 30
ian@0 31 return 0;
ian@0 32 }
ian@0 33
ian@0 34 static struct notifier_block clamp_notifier = {
ian@0 35 .notifier_call = clamp_notifier_call,
ian@0 36 };
ian@0 37
ian@0 38 static int clamp_set(struct wf_control *ct, s32 value)
ian@0 39 {
ian@0 40 if (value)
ian@0 41 printk(KERN_INFO "windfarm: Clamping CPU frequency to "
ian@0 42 "minimum !\n");
ian@0 43 else
ian@0 44 printk(KERN_INFO "windfarm: CPU frequency unclamped !\n");
ian@0 45 clamped = value;
ian@0 46 cpufreq_update_policy(0);
ian@0 47 return 0;
ian@0 48 }
ian@0 49
ian@0 50 static int clamp_get(struct wf_control *ct, s32 *value)
ian@0 51 {
ian@0 52 *value = clamped;
ian@0 53 return 0;
ian@0 54 }
ian@0 55
ian@0 56 static s32 clamp_min(struct wf_control *ct)
ian@0 57 {
ian@0 58 return 0;
ian@0 59 }
ian@0 60
ian@0 61 static s32 clamp_max(struct wf_control *ct)
ian@0 62 {
ian@0 63 return 1;
ian@0 64 }
ian@0 65
ian@0 66 static struct wf_control_ops clamp_ops = {
ian@0 67 .set_value = clamp_set,
ian@0 68 .get_value = clamp_get,
ian@0 69 .get_min = clamp_min,
ian@0 70 .get_max = clamp_max,
ian@0 71 .owner = THIS_MODULE,
ian@0 72 };
ian@0 73
ian@0 74 static int __init wf_cpufreq_clamp_init(void)
ian@0 75 {
ian@0 76 struct wf_control *clamp;
ian@0 77
ian@0 78 /* Don't register on old machines that use therm_pm72 for now */
ian@0 79 if (machine_is_compatible("PowerMac7,2") ||
ian@0 80 machine_is_compatible("PowerMac7,3") ||
ian@0 81 machine_is_compatible("RackMac3,1"))
ian@0 82 return -ENODEV;
ian@0 83
ian@0 84 clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
ian@0 85 if (clamp == NULL)
ian@0 86 return -ENOMEM;
ian@0 87 cpufreq_register_notifier(&clamp_notifier, CPUFREQ_POLICY_NOTIFIER);
ian@0 88 clamp->ops = &clamp_ops;
ian@0 89 clamp->name = "cpufreq-clamp";
ian@0 90 if (wf_register_control(clamp))
ian@0 91 goto fail;
ian@0 92 clamp_control = clamp;
ian@0 93 return 0;
ian@0 94 fail:
ian@0 95 kfree(clamp);
ian@0 96 return -ENODEV;
ian@0 97 }
ian@0 98
ian@0 99 static void __exit wf_cpufreq_clamp_exit(void)
ian@0 100 {
ian@0 101 if (clamp_control)
ian@0 102 wf_unregister_control(clamp_control);
ian@0 103 }
ian@0 104
ian@0 105
ian@0 106 module_init(wf_cpufreq_clamp_init);
ian@0 107 module_exit(wf_cpufreq_clamp_exit);
ian@0 108
ian@0 109 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
ian@0 110 MODULE_DESCRIPTION("CPU frequency clamp for PowerMacs thermal control");
ian@0 111 MODULE_LICENSE("GPL");
ian@0 112