Browse Source

Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq

* master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq:
  [CPUFREQ] constify some data tables.
  [CPUFREQ] constify cpufreq_driver where possible.
  {rd,wr}msr_on_cpu SMP=n optimization
  [CPUFREQ] cpufreq_ondemand.c: don't use _WORK_NAR
  rdmsr_on_cpu, wrmsr_on_cpu
  [CPUFREQ] Revert default on deprecated config X86_SPEEDSTEP_CENTRINO_ACPI
Linus Torvalds 18 years ago
parent
commit
6f8c480f99

+ 0 - 1
arch/i386/kernel/cpu/cpufreq/Kconfig

@@ -125,7 +125,6 @@ config X86_SPEEDSTEP_CENTRINO_ACPI
 	bool "Use ACPI tables to decode valid frequency/voltage (deprecated)"
 	depends on X86_SPEEDSTEP_CENTRINO && ACPI_PROCESSOR
 	depends on !(X86_SPEEDSTEP_CENTRINO = y && ACPI_PROCESSOR = m)
-	default y
 	help
 	  This is deprecated and this functionality is now merged into
 	  acpi_cpufreq (X86_ACPI_CPUFREQ). Use that driver instead of

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c

@@ -373,7 +373,7 @@ static int nforce2_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static struct cpufreq_driver nforce2_driver = {
+static const struct cpufreq_driver nforce2_driver = {
 	.name = "nforce2",
 	.verify = nforce2_verify,
 	.target = nforce2_target,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/e_powersaver.c

@@ -293,7 +293,7 @@ static struct freq_attr* eps_attr[] = {
 	NULL,
 };
 
-static struct cpufreq_driver eps_driver = {
+static const struct cpufreq_driver eps_driver = {
 	.verify		= eps_verify,
 	.target		= eps_target,
 	.init		= eps_cpu_init,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/elanfreq.c

@@ -267,7 +267,7 @@ static struct freq_attr* elanfreq_attr[] = {
 };
 
 
-static struct cpufreq_driver elanfreq_driver = {
+static const struct cpufreq_driver elanfreq_driver = {
 	.get		= elanfreq_get_cpu_frequency,
 	.verify		= elanfreq_verify,
 	.target		= elanfreq_target,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/gx-suspmod.c

@@ -433,7 +433,7 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
  * cpufreq_gx_init:
  *   MediaGX/Geode GX initialize cpufreq driver
  */
-static struct cpufreq_driver gx_suspmod_driver = {
+static const struct cpufreq_driver gx_suspmod_driver = {
 	.get		= gx_get_cpuspeed,
 	.verify		= cpufreq_gx_verify,
 	.target		= cpufreq_gx_target,

+ 3 - 3
arch/i386/kernel/cpu/cpufreq/longhaul.c

@@ -61,8 +61,8 @@ static int cpu_model;
 static unsigned int numscales=16;
 static unsigned int fsb;
 
-static struct mV_pos *vrm_mV_table;
-static unsigned char *mV_vrm_table;
+static const struct mV_pos *vrm_mV_table;
+static const unsigned char *mV_vrm_table;
 struct f_msr {
 	u8 vrm;
 	u8 pos;
@@ -821,7 +821,7 @@ static struct freq_attr* longhaul_attr[] = {
 	NULL,
 };
 
-static struct cpufreq_driver longhaul_driver = {
+static const struct cpufreq_driver longhaul_driver = {
 	.verify	= longhaul_verify,
 	.target	= longhaul_target,
 	.get	= longhaul_get,

+ 13 - 13
arch/i386/kernel/cpu/cpufreq/longhaul.h

@@ -56,7 +56,7 @@ union msr_longhaul {
 /*
  * VIA C3 Samuel 1  & Samuel 2 (stepping 0)
  */
-static int __initdata samuel1_clock_ratio[16] = {
+static const int __initdata samuel1_clock_ratio[16] = {
 	-1, /* 0000 -> RESERVED */
 	30, /* 0001 ->  3.0x */
 	40, /* 0010 ->  4.0x */
@@ -75,7 +75,7 @@ static int __initdata samuel1_clock_ratio[16] = {
 	-1, /* 1111 -> RESERVED */
 };
 
-static int __initdata samuel1_eblcr[16] = {
+static const int __initdata samuel1_eblcr[16] = {
 	50, /* 0000 -> RESERVED */
 	30, /* 0001 ->  3.0x */
 	40, /* 0010 ->  4.0x */
@@ -97,7 +97,7 @@ static int __initdata samuel1_eblcr[16] = {
 /*
  * VIA C3 Samuel2 Stepping 1->15
  */
-static int __initdata samuel2_eblcr[16] = {
+static const int __initdata samuel2_eblcr[16] = {
 	50,  /* 0000 ->  5.0x */
 	30,  /* 0001 ->  3.0x */
 	40,  /* 0010 ->  4.0x */
@@ -119,7 +119,7 @@ static int __initdata samuel2_eblcr[16] = {
 /*
  * VIA C3 Ezra
  */
-static int __initdata ezra_clock_ratio[16] = {
+static const int __initdata ezra_clock_ratio[16] = {
 	100, /* 0000 -> 10.0x */
 	30,  /* 0001 ->  3.0x */
 	40,  /* 0010 ->  4.0x */
@@ -138,7 +138,7 @@ static int __initdata ezra_clock_ratio[16] = {
 	120, /* 1111 -> 12.0x */
 };
 
-static int __initdata ezra_eblcr[16] = {
+static const int __initdata ezra_eblcr[16] = {
 	50,  /* 0000 ->  5.0x */
 	30,  /* 0001 ->  3.0x */
 	40,  /* 0010 ->  4.0x */
@@ -160,7 +160,7 @@ static int __initdata ezra_eblcr[16] = {
 /*
  * VIA C3 (Ezra-T) [C5M].
  */
-static int __initdata ezrat_clock_ratio[32] = {
+static const int __initdata ezrat_clock_ratio[32] = {
 	100, /* 0000 -> 10.0x */
 	30,  /* 0001 ->  3.0x */
 	40,  /* 0010 ->  4.0x */
@@ -196,7 +196,7 @@ static int __initdata ezrat_clock_ratio[32] = {
 	-1,  /* 1111 -> RESERVED (12.0x) */
 };
 
-static int __initdata ezrat_eblcr[32] = {
+static const int __initdata ezrat_eblcr[32] = {
 	50,  /* 0000 ->  5.0x */
 	30,  /* 0001 ->  3.0x */
 	40,  /* 0010 ->  4.0x */
@@ -235,7 +235,7 @@ static int __initdata ezrat_eblcr[32] = {
 /*
  * VIA C3 Nehemiah */
 
-static int __initdata  nehemiah_clock_ratio[32] = {
+static const int __initdata  nehemiah_clock_ratio[32] = {
 	100, /* 0000 -> 10.0x */
 	160, /* 0001 -> 16.0x */
 	40,  /* 0010 ->  4.0x */
@@ -270,7 +270,7 @@ static int __initdata  nehemiah_clock_ratio[32] = {
 	120, /* 1111 -> 12.0x */
 };
 
-static int __initdata nehemiah_eblcr[32] = {
+static const int __initdata nehemiah_eblcr[32] = {
 	50,  /* 0000 ->  5.0x */
 	160, /* 0001 -> 16.0x */
 	40,  /* 0010 ->  4.0x */
@@ -315,7 +315,7 @@ struct mV_pos {
 	unsigned short pos;
 };
 
-static struct mV_pos __initdata vrm85_mV[32] = {
+static const struct mV_pos __initdata vrm85_mV[32] = {
 	{1250, 8},	{1200, 6},	{1150, 4},	{1100, 2},
 	{1050, 0},	{1800, 30},	{1750, 28},	{1700, 26},
 	{1650, 24},	{1600, 22},	{1550, 20},	{1500, 18},
@@ -326,14 +326,14 @@ static struct mV_pos __initdata vrm85_mV[32] = {
 	{1475, 17},	{1425, 15},	{1375, 13},	{1325, 11}
 };
 
-static unsigned char __initdata mV_vrm85[32] = {
+static const unsigned char __initdata mV_vrm85[32] = {
 	0x04,	0x14,	0x03,	0x13,	0x02,	0x12,	0x01,	0x11,
 	0x00,	0x10,	0x0f,	0x1f,	0x0e,	0x1e,	0x0d,	0x1d,
 	0x0c,	0x1c,	0x0b,	0x1b,	0x0a,	0x1a,	0x09,	0x19,
 	0x08,	0x18,	0x07,	0x17,	0x06,	0x16,	0x05,	0x15
 };
 
-static struct mV_pos __initdata mobilevrm_mV[32] = {
+static const struct mV_pos __initdata mobilevrm_mV[32] = {
 	{1750, 31},	{1700, 30},	{1650, 29},	{1600, 28},
 	{1550, 27},	{1500, 26},	{1450, 25},	{1400, 24},
 	{1350, 23},	{1300, 22},	{1250, 21},	{1200, 20},
@@ -344,7 +344,7 @@ static struct mV_pos __initdata mobilevrm_mV[32] = {
 	{675, 3},	{650, 2},	{625, 1},	{600, 0}
 };
 
-static unsigned char __initdata mV_mobilevrm[32] = {
+static const unsigned char __initdata mV_mobilevrm[32] = {
 	0x1f,	0x1e,	0x1d,	0x1c,	0x1b,	0x1a,	0x19,	0x18,
 	0x17,	0x16,	0x15,	0x14,	0x13,	0x12,	0x11,	0x10,
 	0x0f,	0x0e,	0x0d,	0x0c,	0x0b,	0x0a,	0x09,	0x08,

+ 2 - 2
arch/i386/kernel/cpu/cpufreq/longrun.c

@@ -18,7 +18,7 @@
 
 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "longrun", msg)
 
-static struct cpufreq_driver	longrun_driver;
+static const struct cpufreq_driver longrun_driver;
 
 /**
  * longrun_{low,high}_freq is needed for the conversion of cpufreq kHz
@@ -280,7 +280,7 @@ static int __init longrun_cpu_init(struct cpufreq_policy *policy)
 }
 
 
-static struct cpufreq_driver longrun_driver = {
+static const struct cpufreq_driver longrun_driver = {
 	.flags		= CPUFREQ_CONST_LOOPS,
 	.verify		= longrun_verify_policy,
 	.setpolicy	= longrun_set_policy,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/powernow-k6.c

@@ -195,7 +195,7 @@ static struct freq_attr* powernow_k6_attr[] = {
 	NULL,
 };
 
-static struct cpufreq_driver powernow_k6_driver = {
+static const struct cpufreq_driver powernow_k6_driver = {
 	.verify		= powernow_k6_verify,
 	.target		= powernow_k6_target,
 	.init		= powernow_k6_cpu_init,

+ 3 - 3
arch/i386/kernel/cpu/cpufreq/powernow-k7.c

@@ -68,7 +68,7 @@ union powernow_acpi_control_t {
 
 #ifdef CONFIG_CPU_FREQ_DEBUG
 /* divide by 1000 to get VCore voltage in V. */
-static int mobile_vid_table[32] = {
+static const int mobile_vid_table[32] = {
     2000, 1950, 1900, 1850, 1800, 1750, 1700, 1650,
     1600, 1550, 1500, 1450, 1400, 1350, 1300, 0,
     1275, 1250, 1225, 1200, 1175, 1150, 1125, 1100,
@@ -77,7 +77,7 @@ static int mobile_vid_table[32] = {
 #endif
 
 /* divide by 10 to get FID. */
-static int fid_codes[32] = {
+static const int fid_codes[32] = {
     110, 115, 120, 125, 50, 55, 60, 65,
     70, 75, 80, 85, 90, 95, 100, 105,
     30, 190, 40, 200, 130, 135, 140, 210,
@@ -647,7 +647,7 @@ static struct freq_attr* powernow_table_attr[] = {
 	NULL,
 };
 
-static struct cpufreq_driver powernow_driver = {
+static const struct cpufreq_driver powernow_driver = {
 	.verify	= powernow_verify,
 	.target	= powernow_target,
 	.get	= powernow_get,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/powernow-k8.c

@@ -1305,7 +1305,7 @@ static struct freq_attr* powernow_k8_attr[] = {
 	NULL,
 };
 
-static struct cpufreq_driver cpufreq_amd64_driver = {
+static const struct cpufreq_driver cpufreq_amd64_driver = {
 	.verify = powernowk8_verify,
 	.target = powernowk8_target,
 	.init = powernowk8_cpu_init,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/sc520_freq.c

@@ -138,7 +138,7 @@ static struct freq_attr* sc520_freq_attr[] = {
 };
 
 
-static struct cpufreq_driver sc520_freq_driver = {
+static const struct cpufreq_driver sc520_freq_driver = {
 	.get	= sc520_freq_get_cpu_frequency,
 	.verify	= sc520_freq_verify,
 	.target	= sc520_freq_target,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/speedstep-ich.c

@@ -374,7 +374,7 @@ static struct freq_attr* speedstep_attr[] = {
 };
 
 
-static struct cpufreq_driver speedstep_driver = {
+static const struct cpufreq_driver speedstep_driver = {
 	.name	= "speedstep-ich",
 	.verify	= speedstep_verify,
 	.target	= speedstep_target,

+ 1 - 1
arch/i386/kernel/cpu/cpufreq/speedstep-smi.c

@@ -332,7 +332,7 @@ static struct freq_attr* speedstep_attr[] = {
 	NULL,
 };
 
-static struct cpufreq_driver speedstep_driver = {
+static const struct cpufreq_driver speedstep_driver = {
 	.name		= "speedstep-smi",
 	.verify		= speedstep_verify,
 	.target		= speedstep_target,

+ 2 - 0
arch/i386/lib/Makefile

@@ -7,3 +7,5 @@ lib-y = checksum.o delay.o usercopy.o getuser.o putuser.o memcpy.o strstr.o \
 	bitops.o semaphore.o
 
 lib-$(CONFIG_X86_USE_3DNOW) += mmx.o
+
+obj-$(CONFIG_SMP)	+= msr-on-cpu.o

+ 58 - 0
arch/i386/lib/msr-on-cpu.c

@@ -0,0 +1,58 @@
+#include <linux/module.h>
+#include <linux/preempt.h>
+#include <linux/smp.h>
+#include <asm/msr.h>
+
+struct msr_info {
+	u32 msr_no;
+	u32 l, h;
+};
+
+static void __rdmsr_on_cpu(void *info)
+{
+	struct msr_info *rv = info;
+
+	rdmsr(rv->msr_no, rv->l, rv->h);
+}
+
+void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+{
+	preempt_disable();
+	if (smp_processor_id() == cpu)
+		rdmsr(msr_no, *l, *h);
+	else {
+		struct msr_info rv;
+
+		rv.msr_no = msr_no;
+		smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 0, 1);
+		*l = rv.l;
+		*h = rv.h;
+	}
+	preempt_enable();
+}
+
+static void __wrmsr_on_cpu(void *info)
+{
+	struct msr_info *rv = info;
+
+	wrmsr(rv->msr_no, rv->l, rv->h);
+}
+
+void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+{
+	preempt_disable();
+	if (smp_processor_id() == cpu)
+		wrmsr(msr_no, l, h);
+	else {
+		struct msr_info rv;
+
+		rv.msr_no = msr_no;
+		rv.l = l;
+		rv.h = h;
+		smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 0, 1);
+	}
+	preempt_enable();
+}
+
+EXPORT_SYMBOL(rdmsr_on_cpu);
+EXPORT_SYMBOL(wrmsr_on_cpu);

+ 0 - 1
arch/x86_64/kernel/cpufreq/Kconfig

@@ -45,7 +45,6 @@ config X86_SPEEDSTEP_CENTRINO
 config X86_SPEEDSTEP_CENTRINO_ACPI
 	bool
 	depends on X86_SPEEDSTEP_CENTRINO
-	default y
 
 config X86_ACPI_CPUFREQ
 	tristate "ACPI Processor P-States driver"

+ 1 - 0
arch/x86_64/lib/Makefile

@@ -5,6 +5,7 @@
 CFLAGS_csum-partial.o := -funroll-loops
 
 obj-y := io.o iomap_copy.o
+obj-$(CONFIG_SMP)	+= msr-on-cpu.o
 
 lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
 	usercopy.o getuser.o putuser.o  \

+ 1 - 0
arch/x86_64/lib/msr-on-cpu.c

@@ -0,0 +1 @@
+#include "../../i386/lib/msr-on-cpu.c"

+ 2 - 2
drivers/cpufreq/cpufreq.c

@@ -1752,7 +1752,7 @@ static struct notifier_block __cpuinitdata cpufreq_cpu_notifier =
  * (and isn't unregistered in the meantime).
  *
  */
-int cpufreq_register_driver(struct cpufreq_driver *driver_data)
+int cpufreq_register_driver(const struct cpufreq_driver *driver_data)
 {
 	unsigned long flags;
 	int ret;
@@ -1817,7 +1817,7 @@ EXPORT_SYMBOL_GPL(cpufreq_register_driver);
  * Returns zero if successful, and -EINVAL if the cpufreq_driver is
  * currently not initialised.
  */
-int cpufreq_unregister_driver(struct cpufreq_driver *driver)
+int cpufreq_unregister_driver(const struct cpufreq_driver *driver)
 {
 	unsigned long flags;
 

+ 1 - 4
drivers/cpufreq/cpufreq_ondemand.c

@@ -432,9 +432,6 @@ static void do_dbs_timer(struct work_struct *work)
 	/* We want all CPUs to do sampling nearly on same jiffy */
 	int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
 
-	/* Permit rescheduling of this work item */
-	work_release(work);
-
 	delay -= jiffies % delay;
 
 	if (lock_policy_rwsem_write(cpu) < 0)
@@ -473,7 +470,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
 	dbs_info->enable = 1;
 	ondemand_powersave_bias_init();
 	dbs_info->sample_type = DBS_NORMAL_SAMPLE;
-	INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer);
+	INIT_DELAYED_WORK(&dbs_info->work, do_dbs_timer);
 	queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work,
 	                      delay);
 }

+ 14 - 0
include/asm-i386/msr.h

@@ -83,6 +83,20 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
 			  : "c" (counter))
 #endif	/* !CONFIG_PARAVIRT */
 
+#ifdef CONFIG_SMP
+void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
+void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
+#else  /*  CONFIG_SMP  */
+static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+{
+	rdmsr(msr_no, *l, *h);
+}
+static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+{
+	wrmsr(msr_no, l, h);
+}
+#endif  /*  CONFIG_SMP  */
+
 /* symbolic names for some interesting MSRs */
 /* Intel defined MSRs. */
 #define MSR_IA32_P5_MC_ADDR		0

+ 13 - 0
include/asm-x86_64/msr.h

@@ -160,6 +160,19 @@ static inline unsigned int cpuid_edx(unsigned int op)
 #define MSR_IA32_UCODE_WRITE		0x79
 #define MSR_IA32_UCODE_REV		0x8b
 
+#ifdef CONFIG_SMP
+void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
+void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
+#else  /*  CONFIG_SMP  */
+static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+{
+	rdmsr(msr_no, *l, *h);
+}
+static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+{
+	wrmsr(msr_no, l, h);
+}
+#endif  /*  CONFIG_SMP  */
 
 #endif
 

+ 2 - 2
include/linux/cpufreq.h

@@ -225,8 +225,8 @@ struct cpufreq_driver {
 #define CPUFREQ_PM_NO_WARN	0x04	/* don't warn on suspend/resume speed
 					 * mismatches */
 
-int cpufreq_register_driver(struct cpufreq_driver *driver_data);
-int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
+int cpufreq_register_driver(const struct cpufreq_driver *driver_data);
+int cpufreq_unregister_driver(const struct cpufreq_driver *driver_data);
 
 
 void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state);