.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * ARM/ARM64 generic CPU idle driver. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014 ARM Ltd. |
---|
5 | 6 | * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #define pr_fmt(fmt) "CPUidle arm: " fmt |
---|
13 | 10 | |
---|
| 11 | +#include <linux/cpu_cooling.h> |
---|
14 | 12 | #include <linux/cpuidle.h> |
---|
15 | 13 | #include <linux/cpumask.h> |
---|
16 | 14 | #include <linux/cpu_pm.h> |
---|
.. | .. |
---|
18 | 16 | #include <linux/module.h> |
---|
19 | 17 | #include <linux/of.h> |
---|
20 | 18 | #include <linux/slab.h> |
---|
21 | | -#include <linux/topology.h> |
---|
22 | 19 | |
---|
23 | 20 | #include <asm/cpuidle.h> |
---|
24 | 21 | |
---|
.. | .. |
---|
82 | 79 | { |
---|
83 | 80 | int ret; |
---|
84 | 81 | struct cpuidle_driver *drv; |
---|
85 | | - struct cpuidle_device *dev; |
---|
86 | 82 | |
---|
87 | 83 | drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL); |
---|
88 | 84 | if (!drv) |
---|
.. | .. |
---|
110 | 106 | ret = arm_cpuidle_init(cpu); |
---|
111 | 107 | |
---|
112 | 108 | /* |
---|
113 | | - * Allow the initialization to continue for other CPUs, if the reported |
---|
114 | | - * failure is a HW misconfiguration/breakage (-ENXIO). |
---|
| 109 | + * Allow the initialization to continue for other CPUs, if the |
---|
| 110 | + * reported failure is a HW misconfiguration/breakage (-ENXIO). |
---|
| 111 | + * |
---|
| 112 | + * Some platforms do not support idle operations |
---|
| 113 | + * (arm_cpuidle_init() returning -EOPNOTSUPP), we should |
---|
| 114 | + * not flag this case as an error, it is a valid |
---|
| 115 | + * configuration. |
---|
115 | 116 | */ |
---|
116 | 117 | if (ret) { |
---|
117 | | - pr_err("CPU %d failed to init idle CPU ops\n", cpu); |
---|
| 118 | + if (ret != -EOPNOTSUPP) |
---|
| 119 | + pr_err("CPU %d failed to init idle CPU ops\n", cpu); |
---|
118 | 120 | ret = ret == -ENXIO ? 0 : ret; |
---|
119 | 121 | goto out_kfree_drv; |
---|
120 | 122 | } |
---|
121 | 123 | |
---|
122 | | - ret = cpuidle_register_driver(drv); |
---|
123 | | - if (ret) { |
---|
124 | | - if (ret != -EBUSY) |
---|
125 | | - pr_err("Failed to register cpuidle driver\n"); |
---|
| 124 | + ret = cpuidle_register(drv, NULL); |
---|
| 125 | + if (ret) |
---|
126 | 126 | goto out_kfree_drv; |
---|
127 | | - } |
---|
128 | 127 | |
---|
129 | | - dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
---|
130 | | - if (!dev) { |
---|
131 | | - ret = -ENOMEM; |
---|
132 | | - goto out_unregister_drv; |
---|
133 | | - } |
---|
134 | | - dev->cpu = cpu; |
---|
135 | | - |
---|
136 | | - ret = cpuidle_register_device(dev); |
---|
137 | | - if (ret) { |
---|
138 | | - pr_err("Failed to register cpuidle device for CPU %d\n", |
---|
139 | | - cpu); |
---|
140 | | - goto out_kfree_dev; |
---|
141 | | - } |
---|
| 128 | + cpuidle_cooling_register(drv); |
---|
142 | 129 | |
---|
143 | 130 | return 0; |
---|
144 | 131 | |
---|
145 | | -out_kfree_dev: |
---|
146 | | - kfree(dev); |
---|
147 | | -out_unregister_drv: |
---|
148 | | - cpuidle_unregister_driver(drv); |
---|
149 | 132 | out_kfree_drv: |
---|
150 | 133 | kfree(drv); |
---|
151 | 134 | return ret; |
---|
.. | .. |
---|
176 | 159 | while (--cpu >= 0) { |
---|
177 | 160 | dev = per_cpu(cpuidle_devices, cpu); |
---|
178 | 161 | drv = cpuidle_get_cpu_driver(dev); |
---|
179 | | - cpuidle_unregister_device(dev); |
---|
180 | | - cpuidle_unregister_driver(drv); |
---|
181 | | - kfree(dev); |
---|
| 162 | + cpuidle_unregister(drv); |
---|
182 | 163 | kfree(drv); |
---|
183 | 164 | } |
---|
184 | 165 | |
---|