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

Commit 36cccd7d authored by Shiju Mathew's avatar Shiju Mathew Committed by Mahesh Sivasubramanian
Browse files

msm: thermal: Intimate EA driver about core frequency mitigation



Add support in KTM driver to intimate EA driver
the current status of core frequency mitigation.
This is required for scheduler to optimize core
migration.

Change-Id: I6f5c3f7a7fe8656d6c6185ce23bce232c129c3c4
Signed-off-by: default avatarShiju Mathew <shijum@codeaurora.org>
parent e604b3e5
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <linux/sched/rt.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <soc/qcom/msm-core.h>

#define CREATE_TRACE_POINTS
#define TRACE_MSM_THERMAL
@@ -153,6 +154,7 @@ static int pending_cpu_freq = -1;
static long *tsens_temp_at_panic;
static u32 tsens_temp_print;
static uint32_t bucket;
static cpumask_t throttling_mask;

enum thermal_threshold {
	HOTPLUG_THRESHOLD_HIGH,
@@ -374,6 +376,49 @@ enum ocr_request {
	sysfs_attr_init(&ko_attr.attr); \
	_attr_gp.attrs[0] = &ko_attr.attr;

void get_cluster_mask(uint32_t cpu, cpumask_t *mask)
{
	int i;

	cpumask_set_cpu(cpu, mask);
	if (core_ptr) {
		for (i = 0; i < core_ptr->entity_count; i++) {
			struct cluster_info *cluster_ptr =
				&core_ptr->child_entity_ptr[i];
			if (*cluster_ptr->cluster_cores.bits & BIT(cpu)) {
				cpumask_copy(mask,
					&cluster_ptr->cluster_cores);
				break;
			}
		}
	}
}

uint32_t get_core_max_freq(uint32_t cpu)
{
	int i;
	uint32_t max_freq = 0;

	if (core_ptr) {
		for (i = 0; i < core_ptr->entity_count; i++) {
			struct cluster_info *cluster_ptr =
				&core_ptr->child_entity_ptr[i];
			if (*cluster_ptr->cluster_cores.bits & BIT(cpu)) {
				if (cluster_ptr->freq_table)
					max_freq =
					cluster_ptr->freq_table
					[cluster_ptr->freq_idx_high].frequency;
				break;
			}
		}
	} else {
		if (table)
			max_freq = table[limit_idx_high].frequency;
	}

	return max_freq;
}

uint32_t get_core_min_freq(uint32_t cpu)
{
	int i;
@@ -480,8 +525,19 @@ static struct notifier_block msm_thermal_cpufreq_notifier = {
static void update_cpu_freq(int cpu)
{
	int ret = 0;
	cpumask_t mask;

	get_cluster_mask(cpu, &mask);
	if (cpu_online(cpu)) {
		if ((cpumask_intersects(&mask, &throttling_mask))
			&& (cpus[cpu].limited_max_freq
				>= get_core_max_freq(cpu))) {
			cpumask_xor(&throttling_mask, &mask, &throttling_mask);
			set_cpu_throttled(&mask, false);
		} else if (!cpumask_intersects(&mask, &throttling_mask)) {
			cpumask_or(&throttling_mask, &mask, &throttling_mask);
			set_cpu_throttled(&mask, true);
		}
		trace_thermal_pre_frequency_mit(cpu,
			cpus[cpu].limited_max_freq,
			cpus[cpu].limited_min_freq);