diff options
-rw-r--r-- | arch/arm/mach-tegra/board-cardhu.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-enterprise.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-kai.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/include/mach/thermal.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/tegra3_thermal.c | 91 | ||||
-rw-r--r-- | arch/arm/mach-tegra/tegra3_throttle.c | 153 |
6 files changed, 43 insertions, 225 deletions
diff --git a/arch/arm/mach-tegra/board-cardhu.c b/arch/arm/mach-tegra/board-cardhu.c index 0163587b82f5..9083828b8352 100644 --- a/arch/arm/mach-tegra/board-cardhu.c +++ b/arch/arm/mach-tegra/board-cardhu.c @@ -72,19 +72,17 @@ /* All units are in millicelsius */ static struct tegra_thermal_data thermal_data = { - .temp_throttle = 85000, .temp_shutdown = 90000, .temp_offset = TDIODE_OFFSET, /* temps based on tdiode */ #ifdef CONFIG_TEGRA_EDP_LIMITS .edp_offset = TDIODE_OFFSET, /* edp based on tdiode */ .hysteresis_edp = 3000, #endif -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + .temp_throttle = 85000, .tc1 = 0, .tc2 = 1, .passive_delay = 2000, -#else - .hysteresis_throttle = 1000, #endif }; diff --git a/arch/arm/mach-tegra/board-enterprise.c b/arch/arm/mach-tegra/board-enterprise.c index 42d930829166..a95ee617b1a8 100644 --- a/arch/arm/mach-tegra/board-enterprise.c +++ b/arch/arm/mach-tegra/board-enterprise.c @@ -65,19 +65,17 @@ /* All units are in millicelsius */ static struct tegra_thermal_data thermal_data = { - .temp_throttle = 85000, .temp_shutdown = 90000, .temp_offset = TDIODE_OFFSET, /* temps based on tdiode */ #ifdef CONFIG_TEGRA_EDP_LIMITS .edp_offset = TDIODE_OFFSET, /* edp based on tdiode */ .hysteresis_edp = 3000, #endif -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + .temp_throttle = 85000, .tc1 = 0, .tc2 = 1, .passive_delay = 2000, -#else - .hysteresis_throttle = 1000, #endif }; diff --git a/arch/arm/mach-tegra/board-kai.c b/arch/arm/mach-tegra/board-kai.c index 923bd100c839..c455fba4cef9 100644 --- a/arch/arm/mach-tegra/board-kai.c +++ b/arch/arm/mach-tegra/board-kai.c @@ -68,19 +68,17 @@ /* All units are in millicelsius */ static struct tegra_thermal_data thermal_data = { - .temp_throttle = 85000, .temp_shutdown = 90000, .temp_offset = TDIODE_OFFSET, /* temps based on tdiode */ #ifdef CONFIG_TEGRA_EDP_LIMITS .edp_offset = TDIODE_OFFSET, /* edp based on tdiode */ .hysteresis_edp = 3000, #endif -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + .temp_throttle = 85000, .tc1 = 0, .tc2 = 1, .passive_delay = 2000, -#else - .hysteresis_throttle = 1000, #endif }; diff --git a/arch/arm/mach-tegra/include/mach/thermal.h b/arch/arm/mach-tegra/include/mach/thermal.h index ab7b34492d9e..67586224cead 100644 --- a/arch/arm/mach-tegra/include/mach/thermal.h +++ b/arch/arm/mach-tegra/include/mach/thermal.h @@ -19,19 +19,17 @@ /* All units in millicelsius */ struct tegra_thermal_data { - long temp_throttle; long temp_shutdown; long temp_offset; #ifdef CONFIG_TEGRA_EDP_LIMITS long edp_offset; long hysteresis_edp; #endif -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + long temp_throttle; int tc1; int tc2; long passive_delay; -#else - long hysteresis_throttle; #endif }; diff --git a/arch/arm/mach-tegra/tegra3_thermal.c b/arch/arm/mach-tegra/tegra3_thermal.c index 27f7a425e02a..6322eb35ab79 100644 --- a/arch/arm/mach-tegra/tegra3_thermal.c +++ b/arch/arm/mach-tegra/tegra3_thermal.c @@ -37,15 +37,13 @@ struct tegra_thermal { struct tegra_thermal_device *device; - long temp_throttle_tj; long temp_shutdown_tj; -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + long temp_throttle_tj; struct thermal_zone_device *thz; int tc1; int tc2; long passive_delay; -#else - long temp_throttle_low_tj; #endif #ifdef CONFIG_TEGRA_EDP_LIMITS int edp_thermal_zone_val; @@ -62,10 +60,6 @@ static struct tegra_thermal thermal_state = { #endif }; -#ifndef CONFIG_TEGRA_THERMAL_SYSFS -static bool throttle_enb; -#endif - #ifdef CONFIG_TEGRA_EDP_LIMITS static inline long edp2tj(struct tegra_thermal *thermal, long edp_temp) @@ -92,7 +86,7 @@ static inline long tj2dev(struct tegra_thermal_device *dev, return tj_temp - dev->offset; } -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE static int tegra_thermal_zone_bind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdevice) { @@ -152,20 +146,6 @@ static struct thermal_zone_device_ops tegra_thermal_zone_ops = { }; #endif -/* The thermal sysfs handles notifying the throttling - * cooling device */ -#ifndef CONFIG_TEGRA_THERMAL_SYSFS -static void tegra_therm_throttle(bool enable) -{ - if (throttle_enb != enable) { - mutex_lock(&thermal_state.mutex); - tegra_throttling_enable(enable); - throttle_enb = enable; - mutex_unlock(&thermal_state.mutex); - } -} -#endif - /* Make sure this function remains stateless */ void tegra_thermal_alert(void *data) { @@ -187,7 +167,7 @@ void tegra_thermal_alert(void *data) mutex_lock(&thermal_state.mutex); -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE if (thermal->thz) { if (!thermal->thz->passive) thermal_zone_device_update(thermal->thz); @@ -207,17 +187,11 @@ void tegra_thermal_alert(void *data) temp_low_tj = dev2tj(thermal->device, temp_low_dev); lo_limit_throttle_tj = temp_low_tj; + hi_limit_throttle_tj = thermal->temp_shutdown_tj; + +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE hi_limit_throttle_tj = thermal->temp_throttle_tj; -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - /* Check to see if we are currently throttling */ - if ((tegra_is_throttling() && - (temp_tj > thermal->temp_throttle_low_tj)) - || (temp_tj >= thermal->temp_throttle_tj)) { - lo_limit_throttle_tj = thermal->temp_throttle_low_tj; - hi_limit_throttle_tj = thermal->temp_shutdown_tj; - } -#else if (temp_tj > thermal->temp_throttle_tj) { lo_limit_throttle_tj = thermal->temp_throttle_tj; hi_limit_throttle_tj = thermal->temp_shutdown_tj; @@ -262,18 +236,6 @@ void tegra_thermal_alert(void *data) tj2dev(thermal->device, lo_limit_tj), tj2dev(thermal->device, hi_limit_tj)); -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - if (temp_tj >= thermal->temp_throttle_tj) { - /* start throttling */ - if (!tegra_is_throttling()) - tegra_therm_throttle(true); - } else if (temp_tj <= thermal->temp_throttle_low_tj) { - /* switch off throttling */ - if (tegra_is_throttling()) - tegra_therm_throttle(false); - } -#endif - #ifdef CONFIG_TEGRA_EDP_LIMITS /* inform edp governor */ if (thermal->edp_thermal_zone_val != temp_tj) @@ -288,7 +250,7 @@ done: int tegra_thermal_set_device(struct tegra_thermal_device *device) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE struct thermal_zone_device *thz; #endif @@ -298,7 +260,7 @@ int tegra_thermal_set_device(struct tegra_thermal_device *device) thermal_state.device = device; -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE thz = thermal_zone_device_register(thermal_state.device->name, 1, /* trips */ &thermal_state, @@ -330,22 +292,18 @@ int tegra_thermal_set_device(struct tegra_thermal_device *device) int __init tegra_thermal_init(struct tegra_thermal_data *data) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE thermal_state.tc1 = data->tc1; thermal_state.tc2 = data->tc2; thermal_state.passive_delay = data->passive_delay; -#else - thermal_state.temp_throttle_low_tj = data->temp_throttle + - data->temp_offset - - data->hysteresis_throttle; + thermal_state.temp_throttle_tj = data->temp_throttle + + data->temp_offset; #endif mutex_init(&thermal_state.mutex); #ifdef CONFIG_TEGRA_EDP_LIMITS thermal_state.edp_offset = data->edp_offset; thermal_state.hysteresis_edp = data->hysteresis_edp; #endif - thermal_state.temp_throttle_tj = data->temp_throttle + - data->temp_offset; thermal_state.temp_shutdown_tj = data->temp_shutdown + data->temp_offset; @@ -354,7 +312,7 @@ int __init tegra_thermal_init(struct tegra_thermal_data *data) int tegra_thermal_exit(void) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE if (thermal_state.thz) thermal_zone_device_unregister(thermal_state.thz); #endif @@ -364,19 +322,11 @@ int tegra_thermal_exit(void) #ifdef CONFIG_DEBUG_FS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE static int tegra_thermal_throttle_temp_tj_set(void *data, u64 val) { -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - long throttle_hysteresis = thermal_state.temp_throttle_tj - - thermal_state.temp_throttle_low_tj; -#endif - mutex_lock(&thermal_state.mutex); thermal_state.temp_throttle_tj = val; -#ifndef CONFIG_TEGRA_THERMAL_SYSFS - thermal_state.temp_throttle_low_tj = thermal_state.temp_throttle_tj - - throttle_hysteresis; -#endif mutex_unlock(&thermal_state.mutex); tegra_thermal_alert(&thermal_state); @@ -394,6 +344,7 @@ DEFINE_SIMPLE_ATTRIBUTE(throttle_temp_tj_fops, tegra_thermal_throttle_temp_tj_get, tegra_thermal_throttle_temp_tj_set, "%llu\n"); +#endif static int tegra_thermal_shutdown_temp_tj_set(void *data, u64 val) { @@ -447,7 +398,7 @@ DEFINE_SIMPLE_ATTRIBUTE(temp_tj_fops, NULL, "%llu\n"); -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE static int tegra_thermal_tc1_set(void *data, u64 val) { thermal_state.thz->tc1 = val; @@ -507,10 +458,6 @@ static int __init tegra_thermal_debug_init(void) { thermal_debugfs_root = debugfs_create_dir("tegra_thermal", 0); - if (!debugfs_create_file("throttle_temp_tj", 0644, thermal_debugfs_root, - NULL, &throttle_temp_tj_fops)) - goto err_out; - if (!debugfs_create_file("shutdown_temp_tj", 0644, thermal_debugfs_root, NULL, &shutdown_temp_tj_fops)) goto err_out; @@ -519,7 +466,11 @@ static int __init tegra_thermal_debug_init(void) NULL, &temp_tj_fops)) goto err_out; -#ifdef CONFIG_TEGRA_THERMAL_SYSFS +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + if (!debugfs_create_file("throttle_temp_tj", 0644, thermal_debugfs_root, + NULL, &throttle_temp_tj_fops)) + goto err_out; + if (!debugfs_create_file("tc1", 0644, thermal_debugfs_root, NULL, &tc1_fops)) goto err_out; diff --git a/arch/arm/mach-tegra/tegra3_throttle.c b/arch/arm/mach-tegra/tegra3_throttle.c index f927be7800d6..9e8d32fb79fa 100644 --- a/arch/arm/mach-tegra/tegra3_throttle.c +++ b/arch/arm/mach-tegra/tegra3_throttle.c @@ -34,33 +34,26 @@ /* tegra throttling require frequencies in the table to be in ascending order */ static struct cpufreq_frequency_table *cpu_freq_table; -static struct mutex *cpu_throttle_lock; static struct { unsigned int cpu_freq; int core_cap_level; - int ms; } throttle_table[] = { - { 0, 1000, 2000 }, /* placeholder for cpu floor rate */ - { 640000, 1000, 2000 }, - { 640000, 1000, 2000 }, - { 640000, 1000, 2000 }, - { 640000, 1000, 2000 }, - { 640000, 1000, 2000 }, - { 760000, 1000, 2000 }, - { 760000, 1050, 2000 }, - {1000000, 1050, 2000 }, - {1000000, 1100, 2000 }, + { 0, 1000 }, /* placeholder for cpu floor rate */ + { 640000, 1000 }, + { 640000, 1000 }, + { 640000, 1000 }, + { 640000, 1000 }, + { 640000, 1000 }, + { 760000, 1000 }, + { 760000, 1050 }, + {1000000, 1050 }, + {1000000, 1100 }, }; static int is_throttling; static int throttle_index; -static struct delayed_work throttle_work; -static struct workqueue_struct *workqueue; -static DEFINE_MUTEX(tegra_throttle_lock); -#ifdef CONFIG_TEGRA_THERMAL_SYSFS static struct thermal_cooling_device *cdev; -#endif static unsigned int clip_to_table(unsigned int cpu_freq) { @@ -74,81 +67,6 @@ static unsigned int clip_to_table(unsigned int cpu_freq) return cpu_freq_table[i].frequency; } -static void tegra_throttle_work_func(struct work_struct *work) -{ - unsigned int cpu_freq; - int core_level; - - mutex_lock(cpu_throttle_lock); - if (!is_throttling) { - mutex_unlock(cpu_throttle_lock); - return; - } - - cpu_freq = tegra_getspeed(0); - throttle_index -= throttle_index ? 1 : 0; - - core_level = throttle_table[throttle_index].core_cap_level; - if (throttle_table[throttle_index].cpu_freq < cpu_freq) - tegra_cpu_set_speed_cap(NULL); - - if (throttle_index || (throttle_table[0].cpu_freq < cpu_freq)) - queue_delayed_work(workqueue, &throttle_work, - msecs_to_jiffies(throttle_table[throttle_index].ms)); - - mutex_unlock(cpu_throttle_lock); - - tegra_dvfs_core_cap_level_set(core_level); -} - -/* - * tegra_throttling_enable - * This function may sleep - */ -void tegra_throttling_enable(bool enable) -{ - mutex_lock(&tegra_throttle_lock); - mutex_lock(cpu_throttle_lock); - - if (enable && !(is_throttling++)) { - int core_level; - unsigned int cpu_freq = tegra_getspeed(0); - throttle_index = ARRAY_SIZE(throttle_table) - 1; - - core_level = throttle_table[throttle_index].core_cap_level; - if (throttle_table[throttle_index].cpu_freq < cpu_freq) - tegra_cpu_set_speed_cap(NULL); - - queue_delayed_work(workqueue, &throttle_work, - msecs_to_jiffies(throttle_table[throttle_index].ms)); - - mutex_unlock(cpu_throttle_lock); - - tegra_dvfs_core_cap_level_set(core_level); - tegra_dvfs_core_cap_enable(true); - - mutex_unlock(&tegra_throttle_lock); - return; - } - - if (!enable && is_throttling) { - if (!(--is_throttling)) { - /* restore speed requested by governor */ - tegra_cpu_set_speed_cap(NULL); - mutex_unlock(cpu_throttle_lock); - - tegra_dvfs_core_cap_enable(false); - cancel_delayed_work_sync(&throttle_work); - mutex_unlock(&tegra_throttle_lock); - return; - } - } - - mutex_unlock(cpu_throttle_lock); - mutex_unlock(&tegra_throttle_lock); -} -EXPORT_SYMBOL_GPL(tegra_throttling_enable); - unsigned int tegra_throttle_governor_speed(unsigned int requested_speed) { return is_throttling ? @@ -161,8 +79,6 @@ bool tegra_is_throttling(void) return is_throttling; } -#ifdef CONFIG_TEGRA_THERMAL_SYSFS - static int tegra_throttle_get_max_state(struct thermal_cooling_device *cdev, unsigned long *max_state) @@ -175,11 +91,9 @@ static int tegra_throttle_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *cur_state) { - mutex_lock(cpu_throttle_lock); *cur_state = is_throttling ? (ARRAY_SIZE(throttle_table) - throttle_index) : 0; - mutex_unlock(cpu_throttle_lock); return 0; } @@ -190,7 +104,6 @@ tegra_throttle_set_cur_state(struct thermal_cooling_device *cdev, { int core_level; - mutex_lock(cpu_throttle_lock); if (cur_state == 0) { /* restore speed requested by governor */ if (is_throttling) { @@ -212,7 +125,6 @@ tegra_throttle_set_cur_state(struct thermal_cooling_device *cdev, tegra_cpu_set_speed_cap(NULL); } - mutex_unlock(cpu_throttle_lock); return 0; } @@ -222,7 +134,6 @@ struct thermal_cooling_device_ops tegra_throttle_cooling_ops = { .get_cur_state = tegra_throttle_get_cur_state, .set_cur_state = tegra_throttle_set_cur_state, }; -#endif int __init tegra_throttle_init(struct mutex *cpu_lock) { @@ -232,18 +143,6 @@ int __init tegra_throttle_init(struct mutex *cpu_lock) if (IS_ERR_OR_NULL(table_data)) return -EINVAL; - /* - * High-priority, others flags default: not bound to a specific - * CPU, has rescue worker task (in case of allocation deadlock, - * etc.). Single-threaded. - */ - workqueue = alloc_workqueue("cpu-tegra", - WQ_HIGHPRI | WQ_UNBOUND | WQ_RESCUER, 1); - if (!workqueue) - return -ENOMEM; - INIT_DELAYED_WORK(&throttle_work, tegra_throttle_work_func); - - cpu_throttle_lock = cpu_lock; cpu_freq_table = table_data->freq_table; throttle_table[0].cpu_freq = cpu_freq_table[table_data->throttle_lowest_index].frequency; @@ -253,7 +152,6 @@ int __init tegra_throttle_init(struct mutex *cpu_lock) throttle_table[i].cpu_freq = clip_to_table(cpu_freq); } -#ifdef CONFIG_TEGRA_THERMAL_SYSFS cdev = thermal_cooling_device_register("Throttle", NULL, &tegra_throttle_cooling_ops); @@ -261,44 +159,27 @@ int __init tegra_throttle_init(struct mutex *cpu_lock) cdev = NULL; return -ENODEV; } -#endif return 0; } void tegra_throttle_exit(void) { -#ifdef CONFIG_TEGRA_THERMAL_SYSFS if (cdev) { thermal_cooling_device_unregister(cdev); cdev = NULL; } -#endif - destroy_workqueue(workqueue); } #ifdef CONFIG_DEBUG_FS - -static int throttle_debug_set(void *data, u64 val) -{ - tegra_throttling_enable(val); - return 0; -} -static int throttle_debug_get(void *data, u64 *val) -{ - *val = (u64) is_throttling; - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(throttle_fops, throttle_debug_get, throttle_debug_set, - "%llu\n"); static int table_show(struct seq_file *s, void *data) { int i; for (i = 0; i < ARRAY_SIZE(throttle_table); i++) - seq_printf(s, "[%d] = %7u %4d %5d\n", + seq_printf(s, "[%d] = %7u %4d\n", i, throttle_table[i].cpu_freq, - throttle_table[i].core_cap_level, throttle_table[i].ms); + throttle_table[i].core_cap_level); return 0; } @@ -314,7 +195,6 @@ static ssize_t table_write(struct file *file, int table_idx; unsigned int cpu_freq; int core_cap_level; - int ms; if (sizeof(buf) <= count) return -EINVAL; @@ -327,8 +207,8 @@ static ssize_t table_write(struct file *file, buf[count] = '\0'; strim(buf); - if (sscanf(buf, "[%d] = %u %d %d", - &table_idx, &cpu_freq, &core_cap_level, &ms) != 4) + if (sscanf(buf, "[%d] = %u %d", + &table_idx, &cpu_freq, &core_cap_level) != 3) return -1; if ((table_idx < 0) || (table_idx >= ARRAY_SIZE(throttle_table))) @@ -337,7 +217,6 @@ static ssize_t table_write(struct file *file, /* round new settings before updating table */ throttle_table[table_idx].cpu_freq = clip_to_table(cpu_freq); throttle_table[table_idx].core_cap_level = (core_cap_level / 50) * 50; - throttle_table[table_idx].ms = jiffies_to_msecs(msecs_to_jiffies(ms)); return count; } @@ -353,10 +232,6 @@ static const struct file_operations table_fops = { int __init tegra_throttle_debug_init(struct dentry *cpu_tegra_debugfs_root) { - if (!debugfs_create_file("throttle", 0644, cpu_tegra_debugfs_root, - NULL, &throttle_fops)) - return -ENOMEM; - if (!debugfs_create_file("throttle_table", 0644, cpu_tegra_debugfs_root, NULL, &table_fops)) return -ENOMEM; |