From d9460fd227ed2ce52941b6a12ad4de05c195f6aa Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:23 +0800 Subject: ACPI: register ACPI Processor as generic thermal cooling device Register ACPI processor as thermal cooling devices. A combination of processor T-state and P-state are used for thermal throttling. the processor will reduce the frequency first and then set the T-state. we use cpufreq_thermal_reduction_pctg to calculate the cpufreq limit, and call cpufreq_verify_with_limit to set the cpufreq limit. if cpufreq driver is loaded, then we have four cooling state for cpufreq control. cooling state 0: cpufreq limit == max_freq cooling state 1: cpufreq limit == max_freq * 80% cooling state 2: cpufreq limit == max_freq * 60% cooling state 3: cpufreq limit == max_freq * 40% after the cpufreq limit is set to 40 percentage of the max_freq, we use T-state for cooling. eg. a processor has P-state support, and it has 8 T-state (T0-T7), the max_state of the proceesor is 10: state cpufreq-limit T-state 0: max_freq T0 1: max_freq * 80% T0 2: max_freq * 60% T0 3: max_freq * 40% T0 4: max_freq * 40% T1 5: max_freq * 40% T2 6: max_freq * 40% T3 7: max_freq * 40% T4 8: max_freq * 40% T5 9: max_freq * 40% T6 10: max_freq * 40% T7 Signed-off-by: Zhang Rui Signed-off-by: Zhao Yakui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- include/acpi/processor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/acpi') diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 76411b1fc4fd..0787635a11aa 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -4,7 +4,7 @@ #include #include #include - +#include #include #define ACPI_PROCESSOR_BUSY_METRIC 10 @@ -218,7 +218,7 @@ struct acpi_processor { struct acpi_processor_performance *performance; struct acpi_processor_throttling throttling; struct acpi_processor_limit limit; - + struct thermal_cooling_device *cdev; /* the _PDC objects for this processor, if any */ struct acpi_object_list *pdc; }; @@ -330,7 +330,7 @@ extern struct cpuidle_driver acpi_idle_driver; /* in processor_thermal.c */ int acpi_processor_get_limit_info(struct acpi_processor *pr); extern struct file_operations acpi_processor_limit_fops; - +extern struct thermal_cooling_device_ops processor_cooling_ops; #ifdef CONFIG_CPU_FREQ void acpi_thermal_cpufreq_init(void); void acpi_thermal_cpufreq_exit(void); -- cgit v1.2.3 From 207339398ecb0835331c748612898dad2a09fdec Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:21 +0800 Subject: ACPI: attach thermal zone info Intel menlow driver needs to get the pointer of themal_zone_device structure of an ACPI thermal zone. Attach this to each ACPI thermal zone device object. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/bus.c | 25 +++++++++++++++++++++++++ drivers/acpi/thermal.c | 11 +++++++++++ include/acpi/acpi_bus.h | 2 ++ 3 files changed, 38 insertions(+) (limited to 'include/acpi') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 1b4cf984b081..8df325dafe0f 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -122,6 +122,31 @@ int acpi_bus_get_status(struct acpi_device *device) EXPORT_SYMBOL(acpi_bus_get_status); +void acpi_bus_private_data_handler(acpi_handle handle, + u32 function, void *context) +{ + return; +} +EXPORT_SYMBOL(acpi_bus_private_data_handler); + +int acpi_bus_get_private_data(acpi_handle handle, void **data) +{ + acpi_status status = AE_OK; + + if (!*data) + return -EINVAL; + + status = acpi_get_data(handle, acpi_bus_private_data_handler, data); + if (ACPI_FAILURE(status) || !*data) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", + handle)); + return -ENODEV; + } + + return 0; +} +EXPORT_SYMBOL(acpi_bus_get_private_data); + /* -------------------------------------------------------------------------- Power Management -------------------------------------------------------------------------- */ diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index d317da5c6e9c..740036355722 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -1101,6 +1101,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) { int trips = 0; int result; + acpi_status status; int i; if (tz->trips.critical.flags.valid) @@ -1129,6 +1130,15 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) if (result) return result; + status = acpi_attach_data(tz->device->handle, + acpi_bus_private_data_handler, + tz->thermal_zone); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error attaching device data\n")); + return -ENODEV; + } + tz->tz_enabled = 1; printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n", @@ -1142,6 +1152,7 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); thermal_zone_device_unregister(tz->thermal_zone); tz->thermal_zone = NULL; + acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler); } diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index fb7171b1bd22..504af20b10c1 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -321,6 +321,8 @@ struct acpi_bus_event { extern struct kobject *acpi_kobj; extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); +void acpi_bus_private_data_handler(acpi_handle, u32, void *); +int acpi_bus_get_private_data(acpi_handle, void **); /* * External Functions */ -- cgit v1.2.3