Skip to content

Commit 3d339dc

Browse files
dlezcanorjwysocki
authored andcommitted
cpuidle / ACPI : move cpuidle_device field out of the acpi_processor_power structure
Currently we have the cpuidle_device field in the acpi_processor_power structure. This adds a dependency between processor.h and cpuidle.h Although it is not a real problem, removing this dependency has the benefit of separating a bit more the cpuidle code from the rest of the acpi code. Also, the compilation should be a bit improved because we do no longer include cpuidle.h in processor.h. The preprocessor was generating 30418 loc and with this patch it generates 30256 loc for processor_thermal.c, a file which is not concerned at all by cpuidle, like processor_perflib.c and processor_throttling.c. That may sound ridiculous, but "small streams make big rivers" :P This patch moves this field into a static global per cpu variable like what is done in the intel_idle driver. Signed-off-by: Daniel Lezcano <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent ed1511b commit 3d339dc

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

drivers/acpi/processor_idle.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ module_param(bm_check_disable, uint, 0000);
7979
static unsigned int latency_factor __read_mostly = 2;
8080
module_param(latency_factor, uint, 0644);
8181

82+
static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
83+
8284
static int disabled_by_idle_boot_param(void)
8385
{
8486
return boot_option_idle_override == IDLE_POLL ||
@@ -998,7 +1000,7 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
9981000
int i, count = CPUIDLE_DRIVER_STATE_START;
9991001
struct acpi_processor_cx *cx;
10001002
struct cpuidle_state_usage *state_usage;
1001-
struct cpuidle_device *dev = &pr->power.dev;
1003+
struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
10021004

10031005
if (!pr->flags.power_setup_done)
10041006
return -EINVAL;
@@ -1130,6 +1132,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
11301132
int acpi_processor_hotplug(struct acpi_processor *pr)
11311133
{
11321134
int ret = 0;
1135+
struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
11331136

11341137
if (disabled_by_idle_boot_param())
11351138
return 0;
@@ -1145,11 +1148,11 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
11451148
return -ENODEV;
11461149

11471150
cpuidle_pause_and_lock();
1148-
cpuidle_disable_device(&pr->power.dev);
1151+
cpuidle_disable_device(dev);
11491152
acpi_processor_get_power_info(pr);
11501153
if (pr->flags.power) {
11511154
acpi_processor_setup_cpuidle_cx(pr);
1152-
ret = cpuidle_enable_device(&pr->power.dev);
1155+
ret = cpuidle_enable_device(dev);
11531156
}
11541157
cpuidle_resume_and_unlock();
11551158

@@ -1160,6 +1163,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
11601163
{
11611164
int cpu;
11621165
struct acpi_processor *_pr;
1166+
struct cpuidle_device *dev;
11631167

11641168
if (disabled_by_idle_boot_param())
11651169
return 0;
@@ -1190,7 +1194,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
11901194
_pr = per_cpu(processors, cpu);
11911195
if (!_pr || !_pr->flags.power_setup_done)
11921196
continue;
1193-
cpuidle_disable_device(&_pr->power.dev);
1197+
dev = per_cpu(acpi_cpuidle_device, cpu);
1198+
cpuidle_disable_device(dev);
11941199
}
11951200

11961201
/* Populate Updated C-state information */
@@ -1204,7 +1209,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
12041209
acpi_processor_get_power_info(_pr);
12051210
if (_pr->flags.power) {
12061211
acpi_processor_setup_cpuidle_cx(_pr);
1207-
cpuidle_enable_device(&_pr->power.dev);
1212+
dev = per_cpu(acpi_cpuidle_device, cpu);
1213+
cpuidle_enable_device(dev);
12081214
}
12091215
}
12101216
put_online_cpus();
@@ -1220,6 +1226,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
12201226
{
12211227
acpi_status status = 0;
12221228
int retval;
1229+
struct cpuidle_device *dev;
12231230
static int first_run;
12241231

12251232
if (disabled_by_idle_boot_param())
@@ -1265,11 +1272,18 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
12651272
printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
12661273
acpi_idle_driver.name);
12671274
}
1275+
1276+
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1277+
if (!dev)
1278+
return -ENOMEM;
1279+
per_cpu(acpi_cpuidle_device, pr->id) = dev;
1280+
1281+
acpi_processor_setup_cpuidle_cx(pr);
1282+
12681283
/* Register per-cpu cpuidle_device. Cpuidle driver
12691284
* must already be registered before registering device
12701285
*/
1271-
acpi_processor_setup_cpuidle_cx(pr);
1272-
retval = cpuidle_register_device(&pr->power.dev);
1286+
retval = cpuidle_register_device(dev);
12731287
if (retval) {
12741288
if (acpi_processor_registered == 0)
12751289
cpuidle_unregister_driver(&acpi_idle_driver);
@@ -1282,11 +1296,13 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
12821296

12831297
int acpi_processor_power_exit(struct acpi_processor *pr)
12841298
{
1299+
struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
1300+
12851301
if (disabled_by_idle_boot_param())
12861302
return 0;
12871303

12881304
if (pr->flags.power) {
1289-
cpuidle_unregister_device(&pr->power.dev);
1305+
cpuidle_unregister_device(dev);
12901306
acpi_processor_registered--;
12911307
if (acpi_processor_registered == 0)
12921308
cpuidle_unregister_driver(&acpi_idle_driver);

include/acpi/processor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <linux/kernel.h>
55
#include <linux/cpu.h>
6-
#include <linux/cpuidle.h>
76
#include <linux/thermal.h>
87
#include <asm/acpi.h>
98

@@ -64,7 +63,6 @@ struct acpi_processor_cx {
6463
};
6564

6665
struct acpi_processor_power {
67-
struct cpuidle_device dev;
6866
struct acpi_processor_cx *state;
6967
unsigned long bm_check_timestamp;
7068
u32 default_state;

0 commit comments

Comments
 (0)