diff options
-rw-r--r-- | arch/arm/mach-tegra/cpu-tegra.c | 33 | ||||
-rw-r--r-- | arch/arm/mach-tegra/cpu-tegra.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-tegra/tegra3_throttle.c | 11 |
3 files changed, 42 insertions, 7 deletions
diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c index 3ade1eb66cdb..abb067414975 100644 --- a/arch/arm/mach-tegra/cpu-tegra.c +++ b/arch/arm/mach-tegra/cpu-tegra.c @@ -146,10 +146,34 @@ static unsigned int user_cap_speed(unsigned int requested_speed) static ssize_t show_throttle(struct cpufreq_policy *policy, char *buf) { - return sprintf(buf, "%u\n", tegra_is_throttling()); + return sprintf(buf, "%u\n", tegra_is_throttling(NULL)); } cpufreq_freq_attr_ro(throttle); + +static ssize_t show_throttle_count(struct cpufreq_policy *policy, char *buf) +{ + int count; + + tegra_is_throttling(&count); + return sprintf(buf, "%u\n", count); +} + +static struct freq_attr _attr_throttle_count = { + .attr = {.name = "throttle_count", .mode = 0444, }, + .show = show_throttle_count, +}; + +static struct attribute *new_attrs[] = { + &_attr_throttle_count.attr, + NULL +}; + +static struct attribute_group stats_attr_grp = { + .attrs = new_attrs, + .name = "stats" +}; + #endif /* CONFIG_TEGRA_THERMAL_THROTTLE */ #ifdef CONFIG_TEGRA_EDP_LIMITS @@ -743,6 +767,7 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy) static int tegra_cpufreq_policy_notifier( struct notifier_block *nb, unsigned long event, void *data) { + static int once = 1; int i, ret; struct cpufreq_policy *policy = data; @@ -751,6 +776,12 @@ static int tegra_cpufreq_policy_notifier( policy->max, CPUFREQ_RELATION_H, &i); policy_max_speed[policy->cpu] = ret ? policy->max : freq_table[i].frequency; + +#ifdef CONFIG_TEGRA_THERMAL_THROTTLE + if (once && policy->cpu == 0 && + sysfs_merge_group(&policy->kobj, &stats_attr_grp) == 0) + once = 0; +#endif } return NOTIFY_OK; } diff --git a/arch/arm/mach-tegra/cpu-tegra.h b/arch/arm/mach-tegra/cpu-tegra.h index 89a5c308e39c..eeb96bdd6f54 100644 --- a/arch/arm/mach-tegra/cpu-tegra.h +++ b/arch/arm/mach-tegra/cpu-tegra.h @@ -42,6 +42,7 @@ struct balanced_throttle { struct thermal_cooling_device *cdev; struct list_head node; int is_throttling; + int throttle_count; int throttle_index; int throt_tab_size; struct throttle_table throt_tab[MAX_THROT_TABLE_SIZE + 1]; @@ -52,7 +53,7 @@ int tegra_throttle_init(struct mutex *cpu_lock); struct thermal_cooling_device *balanced_throttle_register( struct balanced_throttle *bthrot); void tegra_throttle_exit(void); -bool tegra_is_throttling(void); +bool tegra_is_throttling(int *count); unsigned int tegra_throttle_governor_speed(unsigned int requested_speed); #else static inline int tegra_throttle_init(struct mutex *cpu_lock) @@ -62,7 +63,7 @@ static inline struct thermal_cooling_device *balanced_throttle_register( { return ERR_PTR(-EINVAL); } static inline void tegra_throttle_exit(void) {} -static inline bool tegra_is_throttling(void) +static inline bool tegra_is_throttling(int *count) { return false; } static inline unsigned int tegra_throttle_governor_speed( unsigned int requested_speed) diff --git a/arch/arm/mach-tegra/tegra3_throttle.c b/arch/arm/mach-tegra/tegra3_throttle.c index 37d729a3bfda..afe5774e4dee 100644 --- a/arch/arm/mach-tegra/tegra3_throttle.c +++ b/arch/arm/mach-tegra/tegra3_throttle.c @@ -96,20 +96,22 @@ unsigned int tegra_throttle_governor_speed(unsigned int requested_speed) return throttle_speed; } -bool tegra_is_throttling(void) +bool tegra_is_throttling(int *count) { struct balanced_throttle *bthrot; bool is_throttling = false; + int lcount = 0; mutex_lock(&bthrot_list_lock); list_for_each_entry(bthrot, &bthrot_list, node) { - if (bthrot->is_throttling) { + if (bthrot->is_throttling) is_throttling = true; - break; - } + lcount += bthrot->throttle_count; } mutex_unlock(&bthrot_list_lock); + if (count) + *count = lcount; return is_throttling; } @@ -160,6 +162,7 @@ tegra_throttle_set_cur_state(struct thermal_cooling_device *cdev, if (!bthrot->is_throttling) { tegra_dvfs_core_cap_enable(true); bthrot->is_throttling = true; + bthrot->throttle_count++; } bthrot->throttle_index = bthrot->throt_tab_size - cur_state; |