Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e604b3e5 authored by Mahesh Sivasubramanian's avatar Mahesh Sivasubramanian
Browse files

msm-core: Add API to throttle a CPU from thermal framework



Scheduler should try not to assign tasks to a CPU which is thermally
mitigated. To notify scheduler of thermal mitigation, the thermal module
would notify the msm-core of a mitigation request. The information is
passed to the scheduler using existing API to publish energy numbers to the
scheduler.

Change-Id: Ic29bd89f61275680bba1b2fc6b39fff9f5cfefc8
Signed-off-by: default avatarMahesh Sivasubramanian <msivasub@codeaurora.org>
parent 794f7ffe
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -28,10 +28,6 @@ Optional properties:
                 is no change in threshold. If this property is not
                 present, the power is recalculated only on
                 temperature threshold notifications.
-qcom,throttling-temp: Temperature threshold for cpu frequency mitigation.
                 The value should be set same as the threshold temperature
                 in thermal module - 5 C, such that there is a bandwidth to
                 control the cores before frequency mitigation happens.

[Second level nodes]
Required properties to define per core characteristics:
+16 −10
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ struct cpu_static_info {

static DEFINE_MUTEX(policy_update_mutex);
static DEFINE_MUTEX(kthread_update_mutex);
static DEFINE_SPINLOCK(update_lock);
static struct delayed_work sampling_work;
static struct completion sampling_completion;
static struct task_struct *sampling_task;
@@ -118,9 +119,6 @@ module_param_named(disabled, disabled, int,
		S_IRUGO | S_IWUSR | S_IWGRP);
static bool in_suspend;
static bool activate_power_table;
static int max_throttling_temp = 80; /* in C */
module_param_named(throttling_temp, max_throttling_temp, int,
		S_IRUGO | S_IWUSR | S_IWGRP);

/*
 * Cannot be called from an interrupt context
@@ -195,8 +193,6 @@ static void repopulate_stats(int cpu)
		temp_point = (cpu_node->temp - TEMP_BASE_POINT) / 5;

	cpu_stats[cpu].temp = cpu_node->temp;
	cpu_stats[cpu].throttling = cpu_node->temp >= max_throttling_temp ?
					true : false;
	for (i = 0; i < cpu_node->sp->num_of_freqs; i++)
		pt[i].power = cpu_node->sp->power[temp_point][i];

@@ -208,7 +204,6 @@ void trigger_cpu_pwr_stats_calc(void)
{
	int cpu;
	static long prev_temp[NR_CPUS];
	static DEFINE_SPINLOCK(update_lock);
	struct cpu_activity_info *cpu_node;

	if (disabled)
@@ -232,6 +227,20 @@ void trigger_cpu_pwr_stats_calc(void)
}
EXPORT_SYMBOL(trigger_cpu_pwr_stats_calc);

void set_cpu_throttled(cpumask_t *mask, bool throttling)
{
	int cpu;

	if (!mask)
		return;

	spin_lock(&update_lock);
	for_each_cpu(cpu, mask)
		cpu_stats[cpu].throttling = throttling;
	spin_unlock(&update_lock);
}
EXPORT_SYMBOL(set_cpu_throttled);

static void update_related_freq_table(struct cpufreq_policy *policy)
{
	int cpu, num_of_freqs;
@@ -508,8 +517,7 @@ static int msm_core_stats_init(struct device *dev, int cpu)
	cpu_node = &activity[cpu];
	cpu_stats[cpu].cpu = cpu;
	cpu_stats[cpu].temp = cpu_node->temp;
	cpu_stats[cpu].throttling = cpu_node->temp >= max_throttling_temp ?
					true : false;
	cpu_stats[cpu].throttling = false;

	cpu_stats[cpu].len = cpu_node->sp->num_of_freqs;
	pstate = devm_kzalloc(dev,
@@ -980,8 +988,6 @@ static int msm_core_dev_probe(struct platform_device *pdev)
	if (ret)
		pr_info("msm-core initialized without polling period\n");

	key = "qcom,throttling-temp";
	ret = of_property_read_u32(node, key, &max_throttling_temp);

	ret = uio_init(pdev);
	if (ret)
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __ARCH_ARM_MACH_MSM_CORE_H
#define __ARCH_ARM_MACH_MSM_CORE_H
#ifdef CONFIG_APSS_CORE_EA
void set_cpu_throttled(struct cpumask *mask, bool throttling);
#else
static inline void set_cpu_throttled(struct cpumask *mask, bool throttling) {}
#endif
#endif