diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-05-23 04:33:52 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-05-23 04:33:52 -0400 |
commit | 5a2bff8d7c7f63e2e8d467f66f6492fbb4d9509c (patch) | |
tree | 1342ddd57bbf77147f194723d4841bf5b7beae3f | |
parent | f1a0b8310c99a0e3d579e61d81870caec058db46 (diff) | |
parent | 9076eaca60b3796b3b97d1914c4924c4bc39f066 (diff) |
Merge branch 'pm-cpufreq'
* pm-cpufreq:
cpufreq: arm_big_little_dt: Instantiate as platform_driver
cpufreq: arm_big_little_dt: Register driver only if DT has valid data
cpufreq / e_powersaver: Fix linker error when ACPI processor is a module
cpufreq / intel_pstate: Add additional supported CPU ID
cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT
-rw-r--r-- | drivers/cpufreq/Kconfig.x86 | 2 | ||||
-rw-r--r-- | drivers/cpufreq/arm_big_little_dt.c | 93 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 9 | ||||
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 1 |
4 files changed, 66 insertions, 39 deletions
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index 2b8a8c374548..6bd63d63d356 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
@@ -272,7 +272,7 @@ config X86_LONGHAUL | |||
272 | config X86_E_POWERSAVER | 272 | config X86_E_POWERSAVER |
273 | tristate "VIA C7 Enhanced PowerSaver (DANGEROUS)" | 273 | tristate "VIA C7 Enhanced PowerSaver (DANGEROUS)" |
274 | select CPU_FREQ_TABLE | 274 | select CPU_FREQ_TABLE |
275 | depends on X86_32 | 275 | depends on X86_32 && ACPI_PROCESSOR |
276 | help | 276 | help |
277 | This adds the CPUFreq driver for VIA C7 processors. However, this driver | 277 | This adds the CPUFreq driver for VIA C7 processors. However, this driver |
278 | does not have any safeguards to prevent operating the CPU out of spec | 278 | does not have any safeguards to prevent operating the CPU out of spec |
diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c index 173ed059d95f..fd9e3ea6a480 100644 --- a/drivers/cpufreq/arm_big_little_dt.c +++ b/drivers/cpufreq/arm_big_little_dt.c | |||
@@ -19,70 +19,75 @@ | |||
19 | 19 | ||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
21 | 21 | ||
22 | #include <linux/cpu.h> | ||
22 | #include <linux/cpufreq.h> | 23 | #include <linux/cpufreq.h> |
23 | #include <linux/device.h> | 24 | #include <linux/device.h> |
24 | #include <linux/export.h> | 25 | #include <linux/export.h> |
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | #include <linux/of.h> | 27 | #include <linux/of.h> |
27 | #include <linux/opp.h> | 28 | #include <linux/opp.h> |
29 | #include <linux/platform_device.h> | ||
28 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
29 | #include <linux/types.h> | 31 | #include <linux/types.h> |
30 | #include "arm_big_little.h" | 32 | #include "arm_big_little.h" |
31 | 33 | ||
32 | static int dt_init_opp_table(struct device *cpu_dev) | 34 | /* get cpu node with valid operating-points */ |
35 | static struct device_node *get_cpu_node_with_valid_op(int cpu) | ||
33 | { | 36 | { |
34 | struct device_node *np, *parent; | 37 | struct device_node *np = NULL, *parent; |
35 | int count = 0, ret; | 38 | int count = 0; |
36 | 39 | ||
37 | parent = of_find_node_by_path("/cpus"); | 40 | parent = of_find_node_by_path("/cpus"); |
38 | if (!parent) { | 41 | if (!parent) { |
39 | pr_err("failed to find OF /cpus\n"); | 42 | pr_err("failed to find OF /cpus\n"); |
40 | return -ENOENT; | 43 | return NULL; |
41 | } | 44 | } |
42 | 45 | ||
43 | for_each_child_of_node(parent, np) { | 46 | for_each_child_of_node(parent, np) { |
44 | if (count++ != cpu_dev->id) | 47 | if (count++ != cpu) |
45 | continue; | 48 | continue; |
46 | if (!of_get_property(np, "operating-points", NULL)) { | 49 | if (!of_get_property(np, "operating-points", NULL)) { |
47 | ret = -ENODATA; | 50 | of_node_put(np); |
48 | } else { | 51 | np = NULL; |
49 | cpu_dev->of_node = np; | ||
50 | ret = of_init_opp_table(cpu_dev); | ||
51 | } | 52 | } |
52 | of_node_put(np); | ||
53 | of_node_put(parent); | ||
54 | 53 | ||
55 | return ret; | 54 | break; |
56 | } | 55 | } |
57 | 56 | ||
58 | return -ENODEV; | 57 | of_node_put(parent); |
58 | return np; | ||
59 | } | ||
60 | |||
61 | static int dt_init_opp_table(struct device *cpu_dev) | ||
62 | { | ||
63 | struct device_node *np; | ||
64 | int ret; | ||
65 | |||
66 | np = get_cpu_node_with_valid_op(cpu_dev->id); | ||
67 | if (!np) | ||
68 | return -ENODATA; | ||
69 | |||
70 | cpu_dev->of_node = np; | ||
71 | ret = of_init_opp_table(cpu_dev); | ||
72 | of_node_put(np); | ||
73 | |||
74 | return ret; | ||
59 | } | 75 | } |
60 | 76 | ||
61 | static int dt_get_transition_latency(struct device *cpu_dev) | 77 | static int dt_get_transition_latency(struct device *cpu_dev) |
62 | { | 78 | { |
63 | struct device_node *np, *parent; | 79 | struct device_node *np; |
64 | u32 transition_latency = CPUFREQ_ETERNAL; | 80 | u32 transition_latency = CPUFREQ_ETERNAL; |
65 | int count = 0; | ||
66 | 81 | ||
67 | parent = of_find_node_by_path("/cpus"); | 82 | np = get_cpu_node_with_valid_op(cpu_dev->id); |
68 | if (!parent) { | 83 | if (!np) |
69 | pr_info("Failed to find OF /cpus. Use CPUFREQ_ETERNAL transition latency\n"); | ||
70 | return CPUFREQ_ETERNAL; | 84 | return CPUFREQ_ETERNAL; |
71 | } | ||
72 | |||
73 | for_each_child_of_node(parent, np) { | ||
74 | if (count++ != cpu_dev->id) | ||
75 | continue; | ||
76 | 85 | ||
77 | of_property_read_u32(np, "clock-latency", &transition_latency); | 86 | of_property_read_u32(np, "clock-latency", &transition_latency); |
78 | of_node_put(np); | 87 | of_node_put(np); |
79 | of_node_put(parent); | ||
80 | 88 | ||
81 | return transition_latency; | 89 | pr_debug("%s: clock-latency: %d\n", __func__, transition_latency); |
82 | } | 90 | return transition_latency; |
83 | |||
84 | pr_info("clock-latency isn't found, use CPUFREQ_ETERNAL transition latency\n"); | ||
85 | return CPUFREQ_ETERNAL; | ||
86 | } | 91 | } |
87 | 92 | ||
88 | static struct cpufreq_arm_bL_ops dt_bL_ops = { | 93 | static struct cpufreq_arm_bL_ops dt_bL_ops = { |
@@ -91,17 +96,33 @@ static struct cpufreq_arm_bL_ops dt_bL_ops = { | |||
91 | .init_opp_table = dt_init_opp_table, | 96 | .init_opp_table = dt_init_opp_table, |
92 | }; | 97 | }; |
93 | 98 | ||
94 | static int generic_bL_init(void) | 99 | static int generic_bL_probe(struct platform_device *pdev) |
95 | { | 100 | { |
101 | struct device_node *np; | ||
102 | |||
103 | np = get_cpu_node_with_valid_op(0); | ||
104 | if (!np) | ||
105 | return -ENODEV; | ||
106 | |||
107 | of_node_put(np); | ||
96 | return bL_cpufreq_register(&dt_bL_ops); | 108 | return bL_cpufreq_register(&dt_bL_ops); |
97 | } | 109 | } |
98 | module_init(generic_bL_init); | ||
99 | 110 | ||
100 | static void generic_bL_exit(void) | 111 | static int generic_bL_remove(struct platform_device *pdev) |
101 | { | 112 | { |
102 | return bL_cpufreq_unregister(&dt_bL_ops); | 113 | bL_cpufreq_unregister(&dt_bL_ops); |
114 | return 0; | ||
103 | } | 115 | } |
104 | module_exit(generic_bL_exit); | 116 | |
117 | static struct platform_driver generic_bL_platdrv = { | ||
118 | .driver = { | ||
119 | .name = "arm-bL-cpufreq-dt", | ||
120 | .owner = THIS_MODULE, | ||
121 | }, | ||
122 | .probe = generic_bL_probe, | ||
123 | .remove = generic_bL_remove, | ||
124 | }; | ||
125 | module_platform_driver(generic_bL_platdrv); | ||
105 | 126 | ||
106 | MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>"); | 127 | MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>"); |
107 | MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver via DT"); | 128 | MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver via DT"); |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4b8c7f297d74..2d53f47d1747 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1729,18 +1729,23 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
1729 | /* end old governor */ | 1729 | /* end old governor */ |
1730 | if (data->governor) { | 1730 | if (data->governor) { |
1731 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1731 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
1732 | unlock_policy_rwsem_write(policy->cpu); | ||
1732 | __cpufreq_governor(data, | 1733 | __cpufreq_governor(data, |
1733 | CPUFREQ_GOV_POLICY_EXIT); | 1734 | CPUFREQ_GOV_POLICY_EXIT); |
1735 | lock_policy_rwsem_write(policy->cpu); | ||
1734 | } | 1736 | } |
1735 | 1737 | ||
1736 | /* start new governor */ | 1738 | /* start new governor */ |
1737 | data->governor = policy->governor; | 1739 | data->governor = policy->governor; |
1738 | if (!__cpufreq_governor(data, CPUFREQ_GOV_POLICY_INIT)) { | 1740 | if (!__cpufreq_governor(data, CPUFREQ_GOV_POLICY_INIT)) { |
1739 | if (!__cpufreq_governor(data, CPUFREQ_GOV_START)) | 1741 | if (!__cpufreq_governor(data, CPUFREQ_GOV_START)) { |
1740 | failed = 0; | 1742 | failed = 0; |
1741 | else | 1743 | } else { |
1744 | unlock_policy_rwsem_write(policy->cpu); | ||
1742 | __cpufreq_governor(data, | 1745 | __cpufreq_governor(data, |
1743 | CPUFREQ_GOV_POLICY_EXIT); | 1746 | CPUFREQ_GOV_POLICY_EXIT); |
1747 | lock_policy_rwsem_write(policy->cpu); | ||
1748 | } | ||
1744 | } | 1749 | } |
1745 | 1750 | ||
1746 | if (failed) { | 1751 | if (failed) { |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 9c36ace92a39..07f2840ad805 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -521,6 +521,7 @@ static void intel_pstate_timer_func(unsigned long __data) | |||
521 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { | 521 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { |
522 | ICPU(0x2a, default_policy), | 522 | ICPU(0x2a, default_policy), |
523 | ICPU(0x2d, default_policy), | 523 | ICPU(0x2d, default_policy), |
524 | ICPU(0x3a, default_policy), | ||
524 | {} | 525 | {} |
525 | }; | 526 | }; |
526 | MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); | 527 | MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); |