diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/processor_idle.c | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index ed9a1cc690be..8b433cb08a33 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -28,19 +28,12 @@ | |||
28 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 28 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/init.h> | ||
34 | #include <linux/cpufreq.h> | ||
35 | #include <linux/slab.h> | ||
36 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
37 | #include <linux/dmi.h> | 33 | #include <linux/dmi.h> |
38 | #include <linux/moduleparam.h> | 34 | #include <linux/sched.h> /* need_resched() */ |
39 | #include <linux/sched.h> /* need_resched() */ | ||
40 | #include <linux/pm_qos.h> | ||
41 | #include <linux/clockchips.h> | 35 | #include <linux/clockchips.h> |
42 | #include <linux/cpuidle.h> | 36 | #include <linux/cpuidle.h> |
43 | #include <linux/irqflags.h> | ||
44 | 37 | ||
45 | /* | 38 | /* |
46 | * Include the apic definitions for x86 to have the APIC timer related defines | 39 | * Include the apic definitions for x86 to have the APIC timer related defines |
@@ -52,22 +45,14 @@ | |||
52 | #include <asm/apic.h> | 45 | #include <asm/apic.h> |
53 | #endif | 46 | #endif |
54 | 47 | ||
55 | #include <asm/io.h> | ||
56 | #include <asm/uaccess.h> | ||
57 | |||
58 | #include <acpi/acpi_bus.h> | 48 | #include <acpi/acpi_bus.h> |
59 | #include <acpi/processor.h> | 49 | #include <acpi/processor.h> |
60 | #include <asm/processor.h> | ||
61 | 50 | ||
62 | #define PREFIX "ACPI: " | 51 | #define PREFIX "ACPI: " |
63 | 52 | ||
64 | #define ACPI_PROCESSOR_CLASS "processor" | 53 | #define ACPI_PROCESSOR_CLASS "processor" |
65 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 54 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
66 | ACPI_MODULE_NAME("processor_idle"); | 55 | ACPI_MODULE_NAME("processor_idle"); |
67 | #define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) | ||
68 | #define C2_OVERHEAD 1 /* 1us */ | ||
69 | #define C3_OVERHEAD 1 /* 1us */ | ||
70 | #define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) | ||
71 | 56 | ||
72 | static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; | 57 | static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; |
73 | module_param(max_cstate, uint, 0000); | 58 | module_param(max_cstate, uint, 0000); |
@@ -81,6 +66,8 @@ module_param(latency_factor, uint, 0644); | |||
81 | 66 | ||
82 | static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device); | 67 | static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device); |
83 | 68 | ||
69 | static struct acpi_processor_cx *acpi_cstate[CPUIDLE_STATE_MAX]; | ||
70 | |||
84 | static int disabled_by_idle_boot_param(void) | 71 | static int disabled_by_idle_boot_param(void) |
85 | { | 72 | { |
86 | return boot_option_idle_override == IDLE_POLL || | 73 | return boot_option_idle_override == IDLE_POLL || |
@@ -736,8 +723,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
736 | struct cpuidle_driver *drv, int index) | 723 | struct cpuidle_driver *drv, int index) |
737 | { | 724 | { |
738 | struct acpi_processor *pr; | 725 | struct acpi_processor *pr; |
739 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 726 | struct acpi_processor_cx *cx = acpi_cstate[index]; |
740 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
741 | 727 | ||
742 | pr = __this_cpu_read(processors); | 728 | pr = __this_cpu_read(processors); |
743 | 729 | ||
@@ -760,8 +746,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
760 | */ | 746 | */ |
761 | static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) | 747 | static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) |
762 | { | 748 | { |
763 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 749 | struct acpi_processor_cx *cx = acpi_cstate[index]; |
764 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
765 | 750 | ||
766 | ACPI_FLUSH_CPU_CACHE(); | 751 | ACPI_FLUSH_CPU_CACHE(); |
767 | 752 | ||
@@ -791,8 +776,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
791 | struct cpuidle_driver *drv, int index) | 776 | struct cpuidle_driver *drv, int index) |
792 | { | 777 | { |
793 | struct acpi_processor *pr; | 778 | struct acpi_processor *pr; |
794 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 779 | struct acpi_processor_cx *cx = acpi_cstate[index]; |
795 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
796 | 780 | ||
797 | pr = __this_cpu_read(processors); | 781 | pr = __this_cpu_read(processors); |
798 | 782 | ||
@@ -850,8 +834,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
850 | struct cpuidle_driver *drv, int index) | 834 | struct cpuidle_driver *drv, int index) |
851 | { | 835 | { |
852 | struct acpi_processor *pr; | 836 | struct acpi_processor *pr; |
853 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | 837 | struct acpi_processor_cx *cx = acpi_cstate[index]; |
854 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
855 | 838 | ||
856 | pr = __this_cpu_read(processors); | 839 | pr = __this_cpu_read(processors); |
857 | 840 | ||
@@ -943,13 +926,13 @@ struct cpuidle_driver acpi_idle_driver = { | |||
943 | * device i.e. per-cpu data | 926 | * device i.e. per-cpu data |
944 | * | 927 | * |
945 | * @pr: the ACPI processor | 928 | * @pr: the ACPI processor |
929 | * @dev : the cpuidle device | ||
946 | */ | 930 | */ |
947 | static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) | 931 | static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr, |
932 | struct cpuidle_device *dev) | ||
948 | { | 933 | { |
949 | int i, count = CPUIDLE_DRIVER_STATE_START; | 934 | int i, count = CPUIDLE_DRIVER_STATE_START; |
950 | struct acpi_processor_cx *cx; | 935 | struct acpi_processor_cx *cx; |
951 | struct cpuidle_state_usage *state_usage; | ||
952 | struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); | ||
953 | 936 | ||
954 | if (!pr->flags.power_setup_done) | 937 | if (!pr->flags.power_setup_done) |
955 | return -EINVAL; | 938 | return -EINVAL; |
@@ -968,7 +951,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) | |||
968 | 951 | ||
969 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | 952 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { |
970 | cx = &pr->power.states[i]; | 953 | cx = &pr->power.states[i]; |
971 | state_usage = &dev->states_usage[count]; | ||
972 | 954 | ||
973 | if (!cx->valid) | 955 | if (!cx->valid) |
974 | continue; | 956 | continue; |
@@ -979,8 +961,7 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) | |||
979 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | 961 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) |
980 | continue; | 962 | continue; |
981 | #endif | 963 | #endif |
982 | 964 | acpi_cstate[count] = cx; | |
983 | cpuidle_set_statedata(state_usage, cx); | ||
984 | 965 | ||
985 | count++; | 966 | count++; |
986 | if (count == CPUIDLE_STATE_MAX) | 967 | if (count == CPUIDLE_STATE_MAX) |
@@ -1104,7 +1085,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr) | |||
1104 | cpuidle_disable_device(dev); | 1085 | cpuidle_disable_device(dev); |
1105 | acpi_processor_get_power_info(pr); | 1086 | acpi_processor_get_power_info(pr); |
1106 | if (pr->flags.power) { | 1087 | if (pr->flags.power) { |
1107 | acpi_processor_setup_cpuidle_cx(pr); | 1088 | acpi_processor_setup_cpuidle_cx(pr, dev); |
1108 | ret = cpuidle_enable_device(dev); | 1089 | ret = cpuidle_enable_device(dev); |
1109 | } | 1090 | } |
1110 | cpuidle_resume_and_unlock(); | 1091 | cpuidle_resume_and_unlock(); |
@@ -1162,8 +1143,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) | |||
1162 | continue; | 1143 | continue; |
1163 | acpi_processor_get_power_info(_pr); | 1144 | acpi_processor_get_power_info(_pr); |
1164 | if (_pr->flags.power) { | 1145 | if (_pr->flags.power) { |
1165 | acpi_processor_setup_cpuidle_cx(_pr); | ||
1166 | dev = per_cpu(acpi_cpuidle_device, cpu); | 1146 | dev = per_cpu(acpi_cpuidle_device, cpu); |
1147 | acpi_processor_setup_cpuidle_cx(_pr, dev); | ||
1167 | cpuidle_enable_device(dev); | 1148 | cpuidle_enable_device(dev); |
1168 | } | 1149 | } |
1169 | } | 1150 | } |
@@ -1232,7 +1213,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) | |||
1232 | return -ENOMEM; | 1213 | return -ENOMEM; |
1233 | per_cpu(acpi_cpuidle_device, pr->id) = dev; | 1214 | per_cpu(acpi_cpuidle_device, pr->id) = dev; |
1234 | 1215 | ||
1235 | acpi_processor_setup_cpuidle_cx(pr); | 1216 | acpi_processor_setup_cpuidle_cx(pr, dev); |
1236 | 1217 | ||
1237 | /* Register per-cpu cpuidle_device. Cpuidle driver | 1218 | /* Register per-cpu cpuidle_device. Cpuidle driver |
1238 | * must already be registered before registering device | 1219 | * must already be registered before registering device |