static void check_temp(struct work_struct *work) { struct tsens_device tsens_dev; unsigned long temp = 0; uint32_t max_freq = limited_max_freq; int cpu = 0; int ret = 0; tsens_dev.sensor_num = msm_thermal_info.sensor_id; ret = tsens_get_temp(&tsens_dev, &temp); if (ret) { pr_debug("msm_thermal: Unable to read TSENS sensor %d\n", tsens_dev.sensor_num); goto reschedule; } else pr_info("msm_thermal: TSENS sensor %d (%ld C)\n", tsens_dev.sensor_num, temp); if (temp >= msm_thermal_info.limit_temp) { max_freq = msm_thermal_info.limit_freq; #ifdef CONFIG_PERFLOCK_BOOT_LOCK release_boot_lock(); #endif } else if (temp < msm_thermal_info.limit_temp - msm_thermal_info.temp_hysteresis) max_freq = MSM_CPUFREQ_NO_LIMIT; if (max_freq == limited_max_freq) goto reschedule; for_each_possible_cpu(cpu) { ret = update_cpu_max_freq(cpu, max_freq); if (ret) pr_debug("Unable to limit cpu%d max freq to %d\n", cpu, max_freq); } reschedule: if (enabled) schedule_delayed_work(&check_temp_work, msecs_to_jiffies(msm_thermal_info.poll_ms)); }
static void update_all_cpus_max_freq_if_changed(int new_throttled_bin, unsigned temp) { int cpu; int ret; if (throttled_bin == new_throttled_bin) return; #ifdef CONFIG_PERFLOCK_BOOT_LOCK release_boot_lock(); #endif throttled_bin = new_throttled_bin; /* Update new limits */ for_each_possible_cpu(cpu) { ret = update_cpu_max_freq(cpu, throttled_bin, temp); if (ret) pr_warn("Unable to limit cpu%d\n", cpu); } }
static void __cpuinit check_temp(struct work_struct *work) { static int limit_init; struct tsens_device tsens_dev; long temp = 0; uint32_t max_freq = limited_max_freq; int cpu = 0; int ret = 0; tsens_dev.sensor_num = msm_thermal_info.sensor_id; ret = tsens_get_temp(&tsens_dev, &temp); if (ret) { pr_debug("%s: Unable to read TSENS sensor %d\n", KBUILD_MODNAME, tsens_dev.sensor_num); goto reschedule; } if (!limit_init) { ret = msm_thermal_get_freq_table(); if (ret) goto reschedule; else limit_init = 1; } do_core_control(temp); if (temp >= msm_thermal_info.limit_temp_degC) { pr_info("msm_thermal: TSENS sensor %d (%ld C)\n", tsens_dev.sensor_num, temp); #ifdef CONFIG_PERFLOCK_BOOT_LOCK release_boot_lock(); #endif if (limit_idx == limit_idx_low) goto reschedule; limit_idx -= msm_thermal_info.freq_step; if (limit_idx < limit_idx_low) limit_idx = limit_idx_low; max_freq = table[limit_idx].frequency; } else if (temp < msm_thermal_info.limit_temp_degC - msm_thermal_info.temp_hysteresis_degC) { if (limit_idx == limit_idx_high) goto reschedule; limit_idx += msm_thermal_info.freq_step; if (limit_idx >= limit_idx_high) { limit_idx = limit_idx_high; max_freq = MSM_CPUFREQ_NO_LIMIT; } else max_freq = table[limit_idx].frequency; } if (max_freq == limited_max_freq) goto reschedule; for_each_possible_cpu(cpu) { ret = update_cpu_max_freq(cpu, max_freq); if (ret) pr_debug( "%s: Unable to limit cpu%d max freq to %d\n", KBUILD_MODNAME, cpu, max_freq); } reschedule: if (enabled) schedule_delayed_work(&check_temp_work, msecs_to_jiffies(msm_thermal_info.poll_ms)); }