aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle/cpuidle-arm.c
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2015-03-05 10:44:42 -0500
committerDaniel Lezcano <daniel.lezcano@linaro.org>2015-03-24 09:46:25 -0400
commita0d46a3dfdc3f3d639b3fa84b84a58e116e4bf2c (patch)
tree03716d2b2b72189535bb5dad99ddc7d93de7b0c3 /drivers/cpuidle/cpuidle-arm.c
parent0e0870448aa134e91fafe3c39ae270561b495459 (diff)
ARM: cpuidle: Register per cpuidle device
If the cpuidle init cpu operation returns -ENXIO, therefore reporting HW failure or misconfiguration, the CPUidle driver skips the respective cpuidle device initialization because the associated platform back-end HW is not operational. That prevents the system to crash and allows to handle the error gracefully. For example, on Qcom's platform, each core has a SPM. The device associated with this SPM is initialized before the cpuidle framework. If there is an error in the initialization (eg. error in the DT), the system continues to boot but in degraded mode as some SPM may not be correctly initialized. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Diffstat (limited to 'drivers/cpuidle/cpuidle-arm.c')
-rw-r--r--drivers/cpuidle/cpuidle-arm.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
index 1c94b88a7a7d..545069d5fdfb 100644
--- a/drivers/cpuidle/cpuidle-arm.c
+++ b/drivers/cpuidle/cpuidle-arm.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/slab.h>
20 21
21#include <asm/cpuidle.h> 22#include <asm/cpuidle.h>
22 23
@@ -94,6 +95,7 @@ static int __init arm_idle_init(void)
94{ 95{
95 int cpu, ret; 96 int cpu, ret;
96 struct cpuidle_driver *drv = &arm_idle_driver; 97 struct cpuidle_driver *drv = &arm_idle_driver;
98 struct cpuidle_device *dev;
97 99
98 /* 100 /*
99 * Initialize idle states data, starting at index 1. 101 * Initialize idle states data, starting at index 1.
@@ -105,18 +107,57 @@ static int __init arm_idle_init(void)
105 if (ret <= 0) 107 if (ret <= 0)
106 return ret ? : -ENODEV; 108 return ret ? : -ENODEV;
107 109
110 ret = cpuidle_register_driver(drv);
111 if (ret) {
112 pr_err("Failed to register cpuidle driver\n");
113 return ret;
114 }
115
108 /* 116 /*
109 * Call arch CPU operations in order to initialize 117 * Call arch CPU operations in order to initialize
110 * idle states suspend back-end specific data 118 * idle states suspend back-end specific data
111 */ 119 */
112 for_each_possible_cpu(cpu) { 120 for_each_possible_cpu(cpu) {
113 ret = arm_cpuidle_init(cpu); 121 ret = arm_cpuidle_init(cpu);
122
123 /*
124 * Skip the cpuidle device initialization if the reported
125 * failure is a HW misconfiguration/breakage (-ENXIO).
126 */
127 if (ret == -ENXIO)
128 continue;
129
114 if (ret) { 130 if (ret) {
115 pr_err("CPU %d failed to init idle CPU ops\n", cpu); 131 pr_err("CPU %d failed to init idle CPU ops\n", cpu);
116 return ret; 132 goto out_fail;
133 }
134
135 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
136 if (!dev) {
137 pr_err("Failed to allocate cpuidle device\n");
138 goto out_fail;
139 }
140 dev->cpu = cpu;
141
142 ret = cpuidle_register_device(dev);
143 if (ret) {
144 pr_err("Failed to register cpuidle device for CPU %d\n",
145 cpu);
146 kfree(dev);
147 goto out_fail;
117 } 148 }
118 } 149 }
119 150
120 return cpuidle_register(drv, NULL); 151 return 0;
152out_fail:
153 while (--cpu >= 0) {
154 dev = per_cpu(cpuidle_devices, cpu);
155 cpuidle_unregister_device(dev);
156 kfree(dev);
157 }
158
159 cpuidle_unregister_driver(drv);
160
161 return ret;
121} 162}
122device_initcall(arm_idle_init); 163device_initcall(arm_idle_init);