diff options
author | Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | 2008-02-11 20:46:31 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-02-14 00:09:55 -0500 |
commit | 4fcb2fcd4d0678b8ae103d257dcb28074cbfc7fa (patch) | |
tree | 54bcf486976184804c8fc786d09a04e1ce26ef99 | |
parent | e760e716d47b48caf98da348368fd41b4a9b9e7e (diff) |
ACPI, cpuidle: Clarify C-state description in sysfs
Add a new sysfs entry under cpuidle states. desc - can be used by driver to
communicate to userspace any specific information about the state.
This helps in identifying the exact hardware C-states behind the ACPI C-state
definition.
Idea is to export this through powertop, which will help to map the C-state
reported by powertop to actual hardware C-state.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | arch/x86/kernel/acpi/cstate.c | 2 | ||||
-rw-r--r-- | drivers/acpi/processor_idle.c | 11 | ||||
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 3 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 14 | ||||
-rw-r--r-- | include/acpi/processor.h | 9 | ||||
-rw-r--r-- | include/linux/cpuidle.h | 2 |
6 files changed, 34 insertions, 7 deletions
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c index 10b67170b133..8ca3557a6d59 100644 --- a/arch/x86/kernel/acpi/cstate.c +++ b/arch/x86/kernel/acpi/cstate.c | |||
@@ -126,6 +126,8 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu, | |||
126 | printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " | 126 | printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " |
127 | "state\n", cx->type); | 127 | "state\n", cx->type); |
128 | } | 128 | } |
129 | snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", | ||
130 | cx->address); | ||
129 | 131 | ||
130 | out: | 132 | out: |
131 | set_cpus_allowed(current, saved_mask); | 133 | set_cpus_allowed(current, saved_mask); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 32003fdc91e8..baa389b908e2 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -945,11 +945,16 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) | |||
945 | * Otherwise, ignore this info and continue. | 945 | * Otherwise, ignore this info and continue. |
946 | */ | 946 | */ |
947 | cx.entry_method = ACPI_CSTATE_HALT; | 947 | cx.entry_method = ACPI_CSTATE_HALT; |
948 | snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT"); | ||
948 | } else { | 949 | } else { |
949 | continue; | 950 | continue; |
950 | } | 951 | } |
952 | } else { | ||
953 | snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x", | ||
954 | cx.address); | ||
951 | } | 955 | } |
952 | 956 | ||
957 | |||
953 | obj = &(element->package.elements[2]); | 958 | obj = &(element->package.elements[2]); |
954 | if (obj->type != ACPI_TYPE_INTEGER) | 959 | if (obj->type != ACPI_TYPE_INTEGER) |
955 | continue; | 960 | continue; |
@@ -1643,6 +1648,11 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1643 | return -EINVAL; | 1648 | return -EINVAL; |
1644 | } | 1649 | } |
1645 | 1650 | ||
1651 | for (i = 0; i < CPUIDLE_STATE_MAX; i++) { | ||
1652 | dev->states[i].name[0] = '\0'; | ||
1653 | dev->states[i].desc[0] = '\0'; | ||
1654 | } | ||
1655 | |||
1646 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | 1656 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { |
1647 | cx = &pr->power.states[i]; | 1657 | cx = &pr->power.states[i]; |
1648 | state = &dev->states[count]; | 1658 | state = &dev->states[count]; |
@@ -1659,6 +1669,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1659 | cpuidle_set_statedata(state, cx); | 1669 | cpuidle_set_statedata(state, cx); |
1660 | 1670 | ||
1661 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); | 1671 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); |
1672 | strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); | ||
1662 | state->exit_latency = cx->latency; | 1673 | state->exit_latency = cx->latency; |
1663 | state->target_residency = cx->latency * latency_factor; | 1674 | state->target_residency = cx->latency * latency_factor; |
1664 | state->power_usage = cx->power; | 1675 | state->power_usage = cx->power; |
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 60f71e6345e3..d73663a52324 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -219,7 +219,8 @@ static void poll_idle_init(struct cpuidle_device *dev) | |||
219 | 219 | ||
220 | cpuidle_set_statedata(state, NULL); | 220 | cpuidle_set_statedata(state, NULL); |
221 | 221 | ||
222 | snprintf(state->name, CPUIDLE_NAME_LEN, "C0 (poll idle)"); | 222 | snprintf(state->name, CPUIDLE_NAME_LEN, "C0"); |
223 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); | ||
223 | state->exit_latency = 0; | 224 | state->exit_latency = 0; |
224 | state->target_residency = 0; | 225 | state->target_residency = 0; |
225 | state->power_usage = -1; | 226 | state->power_usage = -1; |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 088ea74edd34..69102ca05685 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -218,16 +218,23 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | |||
218 | return sprintf(buf, "%u\n", state->_name);\ | 218 | return sprintf(buf, "%u\n", state->_name);\ |
219 | } | 219 | } |
220 | 220 | ||
221 | static ssize_t show_state_name(struct cpuidle_state *state, char *buf) | 221 | #define define_show_state_str_function(_name) \ |
222 | { | 222 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ |
223 | return sprintf(buf, "%s\n", state->name); | 223 | { \ |
224 | if (state->_name[0] == '\0')\ | ||
225 | return sprintf(buf, "<null>\n");\ | ||
226 | return sprintf(buf, "%s\n", state->_name);\ | ||
224 | } | 227 | } |
225 | 228 | ||
226 | define_show_state_function(exit_latency) | 229 | define_show_state_function(exit_latency) |
227 | define_show_state_function(power_usage) | 230 | define_show_state_function(power_usage) |
228 | define_show_state_function(usage) | 231 | define_show_state_function(usage) |
229 | define_show_state_function(time) | 232 | define_show_state_function(time) |
233 | define_show_state_str_function(name) | ||
234 | define_show_state_str_function(desc) | ||
235 | |||
230 | define_one_state_ro(name, show_state_name); | 236 | define_one_state_ro(name, show_state_name); |
237 | define_one_state_ro(desc, show_state_desc); | ||
231 | define_one_state_ro(latency, show_state_exit_latency); | 238 | define_one_state_ro(latency, show_state_exit_latency); |
232 | define_one_state_ro(power, show_state_power_usage); | 239 | define_one_state_ro(power, show_state_power_usage); |
233 | define_one_state_ro(usage, show_state_usage); | 240 | define_one_state_ro(usage, show_state_usage); |
@@ -235,6 +242,7 @@ define_one_state_ro(time, show_state_time); | |||
235 | 242 | ||
236 | static struct attribute *cpuidle_state_default_attrs[] = { | 243 | static struct attribute *cpuidle_state_default_attrs[] = { |
237 | &attr_name.attr, | 244 | &attr_name.attr, |
245 | &attr_desc.attr, | ||
238 | &attr_latency.attr, | 246 | &attr_latency.attr, |
239 | &attr_power.attr, | 247 | &attr_power.attr, |
240 | &attr_usage.attr, | 248 | &attr_usage.attr, |
diff --git a/include/acpi/processor.h b/include/acpi/processor.h index cdc8004cfd12..06480bcabfdc 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h | |||
@@ -32,9 +32,11 @@ | |||
32 | #define DOMAIN_COORD_TYPE_SW_ANY 0xfd | 32 | #define DOMAIN_COORD_TYPE_SW_ANY 0xfd |
33 | #define DOMAIN_COORD_TYPE_HW_ALL 0xfe | 33 | #define DOMAIN_COORD_TYPE_HW_ALL 0xfe |
34 | 34 | ||
35 | #define ACPI_CSTATE_SYSTEMIO (0) | 35 | #define ACPI_CSTATE_SYSTEMIO 0 |
36 | #define ACPI_CSTATE_FFH (1) | 36 | #define ACPI_CSTATE_FFH 1 |
37 | #define ACPI_CSTATE_HALT (2) | 37 | #define ACPI_CSTATE_HALT 2 |
38 | |||
39 | #define ACPI_CX_DESC_LEN 32 | ||
38 | 40 | ||
39 | /* Power Management */ | 41 | /* Power Management */ |
40 | 42 | ||
@@ -74,6 +76,7 @@ struct acpi_processor_cx { | |||
74 | u64 time; | 76 | u64 time; |
75 | struct acpi_processor_cx_policy promotion; | 77 | struct acpi_processor_cx_policy promotion; |
76 | struct acpi_processor_cx_policy demotion; | 78 | struct acpi_processor_cx_policy demotion; |
79 | char desc[ACPI_CX_DESC_LEN]; | ||
77 | }; | 80 | }; |
78 | 81 | ||
79 | struct acpi_processor_power { | 82 | struct acpi_processor_power { |
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 385d45b616db..6b72a4584086 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #define CPUIDLE_STATE_MAX 8 | 20 | #define CPUIDLE_STATE_MAX 8 |
21 | #define CPUIDLE_NAME_LEN 16 | 21 | #define CPUIDLE_NAME_LEN 16 |
22 | #define CPUIDLE_DESC_LEN 32 | ||
22 | 23 | ||
23 | struct cpuidle_device; | 24 | struct cpuidle_device; |
24 | 25 | ||
@@ -29,6 +30,7 @@ struct cpuidle_device; | |||
29 | 30 | ||
30 | struct cpuidle_state { | 31 | struct cpuidle_state { |
31 | char name[CPUIDLE_NAME_LEN]; | 32 | char name[CPUIDLE_NAME_LEN]; |
33 | char desc[CPUIDLE_DESC_LEN]; | ||
32 | void *driver_data; | 34 | void *driver_data; |
33 | 35 | ||
34 | unsigned int flags; | 36 | unsigned int flags; |