Loading Documentation/thermal/cpu-cooling-api.txt 0 → 100644 +32 −0 Original line number Diff line number Diff line CPU cooling APIs How To =================================== Written by Amit Daniel Kachhap <amit.kachhap@linaro.org> Updated: 12 May 2012 Copyright (c) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) 0. Introduction The generic cpu cooling(freq clipping) provides registration/unregistration APIs to the caller. The binding of the cooling devices to the trip point is left for the user. The registration APIs returns the cooling device pointer. 1. cpu cooling APIs 1.1 cpufreq registration/unregistration APIs 1.1.1 struct thermal_cooling_device *cpufreq_cooling_register( struct cpumask *clip_cpus) This interface function registers the cpufreq cooling device with the name "thermal-cpufreq-%x". This api can support multiple instances of cpufreq cooling devices. clip_cpus: cpumask of cpus where the frequency constraints will happen. 1.1.2 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) This interface function unregisters the "thermal-cpufreq-%x" cooling device. cdev: Cooling device pointer which has to be unregistered. Documentation/hwmon/exynos4_tmu→Documentation/thermal/exynos_thermal +3 −32 Original line number Diff line number Diff line Loading @@ -46,36 +46,7 @@ The threshold levels are defined as follows: The threshold and each trigger_level are set through the corresponding registers. When an interrupt occurs, this driver notify user space of one of four threshold levels for the interrupt through kobject_uevent_env and sysfs_notify functions. When an interrupt occurs, this driver notify kernel thermal framework with the function exynos4_report_trigger. Although an interrupt condition for level_0 can be set, it is not notified to user space through sysfs_notify function. Sysfs Interface --------------- name name of the temperature sensor RO temp1_input temperature RO temp1_max temperature for level_1 interrupt RO temp1_crit temperature for level_2 interrupt RO temp1_emergency temperature for level_3 interrupt RO temp1_max_alarm alarm for level_1 interrupt RO temp1_crit_alarm alarm for level_2 interrupt RO temp1_emergency_alarm alarm for level_3 interrupt RO it can be used to synchronize the cooling action. Documentation/thermal/sysfs-api.txt +8 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ temperature) and throttle appropriate devices. 1.3 interface for binding a thermal zone device with a thermal cooling device 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev); int trip, struct thermal_cooling_device *cdev, unsigned long upper, unsigned long lower); This interface function bind a thermal cooling device to the certain trip point of a thermal zone device. Loading @@ -93,6 +94,12 @@ temperature) and throttle appropriate devices. cdev: thermal cooling device trip: indicates which trip point the cooling devices is associated with in this thermal zone. upper:the Maximum cooling state for this trip point. THERMAL_NO_LIMIT means no upper limit, and the cooling device can be in max_state. lower:the Minimum cooling state can be used for this trip point. THERMAL_NO_LIMIT means no lower limit, and the cooling device can be in cooling state 0. 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev); Loading drivers/acpi/ec.c +25 −5 Original line number Diff line number Diff line Loading @@ -71,9 +71,6 @@ enum ec_command { #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ #define ACPI_EC_MSI_UDELAY 550 /* Wait 550us for MSI EC */ #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts per one transaction */ enum { EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_GPE_STORM, /* GPE storm detected */ Loading @@ -87,6 +84,15 @@ static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; module_param(ec_delay, uint, 0644); MODULE_PARM_DESC(ec_delay, "Timeout(ms) waited until an EC command completes"); /* * If the number of false interrupts per one transaction exceeds * this threshold, will think there is a GPE storm happened and * will disable the GPE for normal transaction. */ static unsigned int ec_storm_threshold __read_mostly = 8; module_param(ec_storm_threshold, uint, 0644); MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); /* If we find an EC via the ECDT, we need to keep a ptr to its context */ /* External interfaces use first EC only, so remember */ typedef int (*acpi_ec_query_func) (void *data); Loading Loading @@ -319,7 +325,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) msleep(1); /* It is safe to enable the GPE outside of the transaction. */ acpi_enable_gpe(NULL, ec->gpe); } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) { } else if (t->irq_count > ec_storm_threshold) { pr_info(PREFIX "GPE storm detected, " "transactions will use polling mode\n"); set_bit(EC_FLAGS_GPE_STORM, &ec->flags); Loading Loading @@ -924,6 +930,17 @@ static int ec_flag_msi(const struct dmi_system_id *id) return 0; } /* * Clevo M720 notebook actually works ok with IRQ mode, if we lifted * the GPE storm threshold back to 20 */ static int ec_enlarge_storm_threshold(const struct dmi_system_id *id) { pr_debug("Setting the EC GPE storm threshold to 20\n"); ec_storm_threshold = 20; return 0; } static struct dmi_system_id __initdata ec_dmi_table[] = { { ec_skip_dsdt_scan, "Compal JFL92", { Loading Loading @@ -955,10 +972,13 @@ static struct dmi_system_id __initdata ec_dmi_table[] = { { ec_validate_ecdt, "ASUS hardware", { DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL}, { ec_enlarge_storm_threshold, "CLEVO hardware", { DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."), DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL}, {}, }; int __init acpi_ec_ecdt_probe(void) { acpi_status status; Loading drivers/acpi/thermal.c +71 −22 Original line number Diff line number Diff line Loading @@ -708,6 +708,40 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal, return -EINVAL; } static int thermal_get_trend(struct thermal_zone_device *thermal, int trip, enum thermal_trend *trend) { struct acpi_thermal *tz = thermal->devdata; enum thermal_trip_type type; int i; if (thermal_get_trip_type(thermal, trip, &type)) return -EINVAL; if (type == THERMAL_TRIP_ACTIVE) { /* aggressive active cooling */ *trend = THERMAL_TREND_RAISING; return 0; } /* * tz->temperature has already been updated by generic thermal layer, * before this callback being invoked */ i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) + (tz->trips.passive.tc2 * (tz->temperature - tz->trips.passive.temperature)); if (i > 0) *trend = THERMAL_TREND_RAISING; else if (i < 0) *trend = THERMAL_TREND_DROPPING; else *trend = THERMAL_TREND_STABLE; return 0; } static int thermal_notify(struct thermal_zone_device *thermal, int trip, enum thermal_trip_type trip_type) { Loading @@ -731,11 +765,9 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip, return 0; } typedef int (*cb)(struct thermal_zone_device *, int, struct thermal_cooling_device *); static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev, cb action) bool bind) { struct acpi_device *device = cdev->devdata; struct acpi_thermal *tz = thermal->devdata; Loading @@ -759,13 +791,21 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, i++) { handle = tz->trips.passive.devices.handles[i]; status = acpi_bus_get_device(handle, &dev); if (ACPI_SUCCESS(status) && (dev == device)) { result = action(thermal, trip, cdev); if (ACPI_FAILURE(status) || dev != device) continue; if (bind) result = thermal_zone_bind_cooling_device (thermal, trip, cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); else result = thermal_zone_unbind_cooling_device (thermal, trip, cdev); if (result) goto failed; } } } for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { if (!tz->trips.active[i].flags.valid) Loading @@ -776,19 +816,32 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, j++) { handle = tz->trips.active[i].devices.handles[j]; status = acpi_bus_get_device(handle, &dev); if (ACPI_SUCCESS(status) && (dev == device)) { result = action(thermal, trip, cdev); if (ACPI_FAILURE(status) || dev != device) continue; if (bind) result = thermal_zone_bind_cooling_device (thermal, trip, cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); else result = thermal_zone_unbind_cooling_device (thermal, trip, cdev); if (result) goto failed; } } } for (i = 0; i < tz->devices.count; i++) { handle = tz->devices.handles[i]; status = acpi_bus_get_device(handle, &dev); if (ACPI_SUCCESS(status) && (dev == device)) { result = action(thermal, -1, cdev); if (bind) result = thermal_zone_bind_cooling_device (thermal, -1, cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); else result = thermal_zone_unbind_cooling_device (thermal, -1, cdev); if (result) goto failed; } Loading @@ -802,16 +855,14 @@ static int acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { return acpi_thermal_cooling_device_cb(thermal, cdev, thermal_zone_bind_cooling_device); return acpi_thermal_cooling_device_cb(thermal, cdev, true); } static int acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { return acpi_thermal_cooling_device_cb(thermal, cdev, thermal_zone_unbind_cooling_device); return acpi_thermal_cooling_device_cb(thermal, cdev, false); } static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { Loading @@ -823,6 +874,7 @@ static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { .get_trip_type = thermal_get_trip_type, .get_trip_temp = thermal_get_trip_temp, .get_crit_temp = thermal_get_crit_temp, .get_trend = thermal_get_trend, .notify = thermal_notify, }; Loading @@ -849,15 +901,12 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz, &acpi_thermal_zone_ops, tz->trips.passive.tc1, tz->trips.passive.tc2, tz->trips.passive.tsp*100, tz->polling_frequency*100); else tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz, &acpi_thermal_zone_ops, 0, 0, 0, &acpi_thermal_zone_ops, 0, tz->polling_frequency*100); if (IS_ERR(tz->thermal_zone)) return -ENODEV; Loading Loading
Documentation/thermal/cpu-cooling-api.txt 0 → 100644 +32 −0 Original line number Diff line number Diff line CPU cooling APIs How To =================================== Written by Amit Daniel Kachhap <amit.kachhap@linaro.org> Updated: 12 May 2012 Copyright (c) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) 0. Introduction The generic cpu cooling(freq clipping) provides registration/unregistration APIs to the caller. The binding of the cooling devices to the trip point is left for the user. The registration APIs returns the cooling device pointer. 1. cpu cooling APIs 1.1 cpufreq registration/unregistration APIs 1.1.1 struct thermal_cooling_device *cpufreq_cooling_register( struct cpumask *clip_cpus) This interface function registers the cpufreq cooling device with the name "thermal-cpufreq-%x". This api can support multiple instances of cpufreq cooling devices. clip_cpus: cpumask of cpus where the frequency constraints will happen. 1.1.2 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) This interface function unregisters the "thermal-cpufreq-%x" cooling device. cdev: Cooling device pointer which has to be unregistered.
Documentation/hwmon/exynos4_tmu→Documentation/thermal/exynos_thermal +3 −32 Original line number Diff line number Diff line Loading @@ -46,36 +46,7 @@ The threshold levels are defined as follows: The threshold and each trigger_level are set through the corresponding registers. When an interrupt occurs, this driver notify user space of one of four threshold levels for the interrupt through kobject_uevent_env and sysfs_notify functions. When an interrupt occurs, this driver notify kernel thermal framework with the function exynos4_report_trigger. Although an interrupt condition for level_0 can be set, it is not notified to user space through sysfs_notify function. Sysfs Interface --------------- name name of the temperature sensor RO temp1_input temperature RO temp1_max temperature for level_1 interrupt RO temp1_crit temperature for level_2 interrupt RO temp1_emergency temperature for level_3 interrupt RO temp1_max_alarm alarm for level_1 interrupt RO temp1_crit_alarm alarm for level_2 interrupt RO temp1_emergency_alarm alarm for level_3 interrupt RO it can be used to synchronize the cooling action.
Documentation/thermal/sysfs-api.txt +8 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ temperature) and throttle appropriate devices. 1.3 interface for binding a thermal zone device with a thermal cooling device 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev); int trip, struct thermal_cooling_device *cdev, unsigned long upper, unsigned long lower); This interface function bind a thermal cooling device to the certain trip point of a thermal zone device. Loading @@ -93,6 +94,12 @@ temperature) and throttle appropriate devices. cdev: thermal cooling device trip: indicates which trip point the cooling devices is associated with in this thermal zone. upper:the Maximum cooling state for this trip point. THERMAL_NO_LIMIT means no upper limit, and the cooling device can be in max_state. lower:the Minimum cooling state can be used for this trip point. THERMAL_NO_LIMIT means no lower limit, and the cooling device can be in cooling state 0. 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, int trip, struct thermal_cooling_device *cdev); Loading
drivers/acpi/ec.c +25 −5 Original line number Diff line number Diff line Loading @@ -71,9 +71,6 @@ enum ec_command { #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ #define ACPI_EC_MSI_UDELAY 550 /* Wait 550us for MSI EC */ #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts per one transaction */ enum { EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_GPE_STORM, /* GPE storm detected */ Loading @@ -87,6 +84,15 @@ static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; module_param(ec_delay, uint, 0644); MODULE_PARM_DESC(ec_delay, "Timeout(ms) waited until an EC command completes"); /* * If the number of false interrupts per one transaction exceeds * this threshold, will think there is a GPE storm happened and * will disable the GPE for normal transaction. */ static unsigned int ec_storm_threshold __read_mostly = 8; module_param(ec_storm_threshold, uint, 0644); MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); /* If we find an EC via the ECDT, we need to keep a ptr to its context */ /* External interfaces use first EC only, so remember */ typedef int (*acpi_ec_query_func) (void *data); Loading Loading @@ -319,7 +325,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) msleep(1); /* It is safe to enable the GPE outside of the transaction. */ acpi_enable_gpe(NULL, ec->gpe); } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) { } else if (t->irq_count > ec_storm_threshold) { pr_info(PREFIX "GPE storm detected, " "transactions will use polling mode\n"); set_bit(EC_FLAGS_GPE_STORM, &ec->flags); Loading Loading @@ -924,6 +930,17 @@ static int ec_flag_msi(const struct dmi_system_id *id) return 0; } /* * Clevo M720 notebook actually works ok with IRQ mode, if we lifted * the GPE storm threshold back to 20 */ static int ec_enlarge_storm_threshold(const struct dmi_system_id *id) { pr_debug("Setting the EC GPE storm threshold to 20\n"); ec_storm_threshold = 20; return 0; } static struct dmi_system_id __initdata ec_dmi_table[] = { { ec_skip_dsdt_scan, "Compal JFL92", { Loading Loading @@ -955,10 +972,13 @@ static struct dmi_system_id __initdata ec_dmi_table[] = { { ec_validate_ecdt, "ASUS hardware", { DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL}, { ec_enlarge_storm_threshold, "CLEVO hardware", { DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."), DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL}, {}, }; int __init acpi_ec_ecdt_probe(void) { acpi_status status; Loading
drivers/acpi/thermal.c +71 −22 Original line number Diff line number Diff line Loading @@ -708,6 +708,40 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal, return -EINVAL; } static int thermal_get_trend(struct thermal_zone_device *thermal, int trip, enum thermal_trend *trend) { struct acpi_thermal *tz = thermal->devdata; enum thermal_trip_type type; int i; if (thermal_get_trip_type(thermal, trip, &type)) return -EINVAL; if (type == THERMAL_TRIP_ACTIVE) { /* aggressive active cooling */ *trend = THERMAL_TREND_RAISING; return 0; } /* * tz->temperature has already been updated by generic thermal layer, * before this callback being invoked */ i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) + (tz->trips.passive.tc2 * (tz->temperature - tz->trips.passive.temperature)); if (i > 0) *trend = THERMAL_TREND_RAISING; else if (i < 0) *trend = THERMAL_TREND_DROPPING; else *trend = THERMAL_TREND_STABLE; return 0; } static int thermal_notify(struct thermal_zone_device *thermal, int trip, enum thermal_trip_type trip_type) { Loading @@ -731,11 +765,9 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip, return 0; } typedef int (*cb)(struct thermal_zone_device *, int, struct thermal_cooling_device *); static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev, cb action) bool bind) { struct acpi_device *device = cdev->devdata; struct acpi_thermal *tz = thermal->devdata; Loading @@ -759,13 +791,21 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, i++) { handle = tz->trips.passive.devices.handles[i]; status = acpi_bus_get_device(handle, &dev); if (ACPI_SUCCESS(status) && (dev == device)) { result = action(thermal, trip, cdev); if (ACPI_FAILURE(status) || dev != device) continue; if (bind) result = thermal_zone_bind_cooling_device (thermal, trip, cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); else result = thermal_zone_unbind_cooling_device (thermal, trip, cdev); if (result) goto failed; } } } for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { if (!tz->trips.active[i].flags.valid) Loading @@ -776,19 +816,32 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, j++) { handle = tz->trips.active[i].devices.handles[j]; status = acpi_bus_get_device(handle, &dev); if (ACPI_SUCCESS(status) && (dev == device)) { result = action(thermal, trip, cdev); if (ACPI_FAILURE(status) || dev != device) continue; if (bind) result = thermal_zone_bind_cooling_device (thermal, trip, cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); else result = thermal_zone_unbind_cooling_device (thermal, trip, cdev); if (result) goto failed; } } } for (i = 0; i < tz->devices.count; i++) { handle = tz->devices.handles[i]; status = acpi_bus_get_device(handle, &dev); if (ACPI_SUCCESS(status) && (dev == device)) { result = action(thermal, -1, cdev); if (bind) result = thermal_zone_bind_cooling_device (thermal, -1, cdev, THERMAL_NO_LIMIT, THERMAL_NO_LIMIT); else result = thermal_zone_unbind_cooling_device (thermal, -1, cdev); if (result) goto failed; } Loading @@ -802,16 +855,14 @@ static int acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { return acpi_thermal_cooling_device_cb(thermal, cdev, thermal_zone_bind_cooling_device); return acpi_thermal_cooling_device_cb(thermal, cdev, true); } static int acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { return acpi_thermal_cooling_device_cb(thermal, cdev, thermal_zone_unbind_cooling_device); return acpi_thermal_cooling_device_cb(thermal, cdev, false); } static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { Loading @@ -823,6 +874,7 @@ static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { .get_trip_type = thermal_get_trip_type, .get_trip_temp = thermal_get_trip_temp, .get_crit_temp = thermal_get_crit_temp, .get_trend = thermal_get_trend, .notify = thermal_notify, }; Loading @@ -849,15 +901,12 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz, &acpi_thermal_zone_ops, tz->trips.passive.tc1, tz->trips.passive.tc2, tz->trips.passive.tsp*100, tz->polling_frequency*100); else tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz, &acpi_thermal_zone_ops, 0, 0, 0, &acpi_thermal_zone_ops, 0, tz->polling_frequency*100); if (IS_ERR(tz->thermal_zone)) return -ENODEV; Loading