Просмотр исходного кода

Merge branch 'pm-cpufreq'

* pm-cpufreq:
  cpufreq / governor: Fix problem with cpufreq_ondemand or cpufreq_conservative
  cpufreq / Longhaul: Disable driver by default
  cpufreq / stats: fix race between stats allocation and first usage
Rafael J. Wysocki 13 лет назад
Родитель
Сommit
f3ea36aa87
4 измененных файлов с 24 добавлено и 7 удалено
  1. 5 0
      drivers/cpufreq/Kconfig
  2. 3 2
      drivers/cpufreq/Makefile
  3. 7 4
      drivers/cpufreq/cpufreq_stats.c
  4. 9 1
      drivers/cpufreq/longhaul.c

+ 5 - 0
drivers/cpufreq/Kconfig

@@ -20,6 +20,9 @@ if CPU_FREQ
 config CPU_FREQ_TABLE
 config CPU_FREQ_TABLE
 	tristate
 	tristate
 
 
+config CPU_FREQ_GOV_COMMON
+	bool
+
 config CPU_FREQ_STAT
 config CPU_FREQ_STAT
 	tristate "CPU frequency translation statistics"
 	tristate "CPU frequency translation statistics"
 	select CPU_FREQ_TABLE
 	select CPU_FREQ_TABLE
@@ -141,6 +144,7 @@ config CPU_FREQ_GOV_USERSPACE
 config CPU_FREQ_GOV_ONDEMAND
 config CPU_FREQ_GOV_ONDEMAND
 	tristate "'ondemand' cpufreq policy governor"
 	tristate "'ondemand' cpufreq policy governor"
 	select CPU_FREQ_TABLE
 	select CPU_FREQ_TABLE
+	select CPU_FREQ_GOV_COMMON
 	help
 	help
 	  'ondemand' - This driver adds a dynamic cpufreq policy governor.
 	  'ondemand' - This driver adds a dynamic cpufreq policy governor.
 	  The governor does a periodic polling and 
 	  The governor does a periodic polling and 
@@ -159,6 +163,7 @@ config CPU_FREQ_GOV_ONDEMAND
 config CPU_FREQ_GOV_CONSERVATIVE
 config CPU_FREQ_GOV_CONSERVATIVE
 	tristate "'conservative' cpufreq governor"
 	tristate "'conservative' cpufreq governor"
 	depends on CPU_FREQ
 	depends on CPU_FREQ
+	select CPU_FREQ_GOV_COMMON
 	help
 	help
 	  'conservative' - this driver is rather similar to the 'ondemand'
 	  'conservative' - this driver is rather similar to the 'ondemand'
 	  governor both in its source code and its purpose, the difference is
 	  governor both in its source code and its purpose, the difference is

+ 3 - 2
drivers/cpufreq/Makefile

@@ -7,8 +7,9 @@ obj-$(CONFIG_CPU_FREQ_STAT)             += cpufreq_stats.o
 obj-$(CONFIG_CPU_FREQ_GOV_PERFORMANCE)	+= cpufreq_performance.o
 obj-$(CONFIG_CPU_FREQ_GOV_PERFORMANCE)	+= cpufreq_performance.o
 obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE)	+= cpufreq_powersave.o
 obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE)	+= cpufreq_powersave.o
 obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE)	+= cpufreq_userspace.o
 obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE)	+= cpufreq_userspace.o
-obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND)	+= cpufreq_ondemand.o cpufreq_governor.o
-obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE)	+= cpufreq_conservative.o cpufreq_governor.o
+obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND)	+= cpufreq_ondemand.o
+obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE)	+= cpufreq_conservative.o
+obj-$(CONFIG_CPU_FREQ_GOV_COMMON)		+= cpufreq_governor.o
 
 
 # CPUfreq cross-arch helpers
 # CPUfreq cross-arch helpers
 obj-$(CONFIG_CPU_FREQ_TABLE)		+= freq_table.o
 obj-$(CONFIG_CPU_FREQ_TABLE)		+= freq_table.o

+ 7 - 4
drivers/cpufreq/cpufreq_stats.c

@@ -364,18 +364,21 @@ static int __init cpufreq_stats_init(void)
 	if (ret)
 	if (ret)
 		return ret;
 		return ret;
 
 
+	register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
+	for_each_online_cpu(cpu)
+		cpufreq_update_policy(cpu);
+
 	ret = cpufreq_register_notifier(&notifier_trans_block,
 	ret = cpufreq_register_notifier(&notifier_trans_block,
 				CPUFREQ_TRANSITION_NOTIFIER);
 				CPUFREQ_TRANSITION_NOTIFIER);
 	if (ret) {
 	if (ret) {
 		cpufreq_unregister_notifier(&notifier_policy_block,
 		cpufreq_unregister_notifier(&notifier_policy_block,
 				CPUFREQ_POLICY_NOTIFIER);
 				CPUFREQ_POLICY_NOTIFIER);
+		unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
+		for_each_online_cpu(cpu)
+			cpufreq_stats_free_table(cpu);
 		return ret;
 		return ret;
 	}
 	}
 
 
-	register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
-	for_each_online_cpu(cpu) {
-		cpufreq_update_policy(cpu);
-	}
 	return 0;
 	return 0;
 }
 }
 static void __exit cpufreq_stats_exit(void)
 static void __exit cpufreq_stats_exit(void)

+ 9 - 1
drivers/cpufreq/longhaul.c

@@ -77,7 +77,7 @@ static unsigned int longhaul_index;
 static int scale_voltage;
 static int scale_voltage;
 static int disable_acpi_c3;
 static int disable_acpi_c3;
 static int revid_errata;
 static int revid_errata;
-
+static int enable;
 
 
 /* Clock ratios multiplied by 10 */
 /* Clock ratios multiplied by 10 */
 static int mults[32];
 static int mults[32];
@@ -965,6 +965,10 @@ static int __init longhaul_init(void)
 	if (!x86_match_cpu(longhaul_id))
 	if (!x86_match_cpu(longhaul_id))
 		return -ENODEV;
 		return -ENODEV;
 
 
+	if (!enable) {
+		printk(KERN_ERR PFX "Option \"enable\" not set. Aborting.\n");
+		return -ENODEV;
+	}
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 	if (num_online_cpus() > 1) {
 	if (num_online_cpus() > 1) {
 		printk(KERN_ERR PFX "More than 1 CPU detected, "
 		printk(KERN_ERR PFX "More than 1 CPU detected, "
@@ -1021,6 +1025,10 @@ MODULE_PARM_DESC(scale_voltage, "Scale voltage of processor");
  * such. */
  * such. */
 module_param(revid_errata, int, 0644);
 module_param(revid_errata, int, 0644);
 MODULE_PARM_DESC(revid_errata, "Ignore CPU Revision ID");
 MODULE_PARM_DESC(revid_errata, "Ignore CPU Revision ID");
+/* By default driver is disabled to prevent incompatible
+ * system freeze. */
+module_param(enable, int, 0644);
+MODULE_PARM_DESC(enable, "Enable driver");
 
 
 MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
 MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
 MODULE_DESCRIPTION("Longhaul driver for VIA Cyrix processors.");
 MODULE_DESCRIPTION("Longhaul driver for VIA Cyrix processors.");