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

Commit 20ac93b6 authored by Satya Durga Srinivasu Prabhala's avatar Satya Durga Srinivasu Prabhala Committed by Gerrit - the friendly Code Review server
Browse files

drivers: thermal: reintroduce notifier for max level transitions



commit 547ecd3b
("drivers: thermal: cpu_cooling: Add a notifier for max level transitions")
introduced notifier for max level transitions earlier, later, thermal
drivers got refractored and removed chunk of code that was introduced
to support notifier for max level transitions. Bringing back the code
that was removed on top of refactored thermal code.

Change-Id: Ifeb3a73a074d04f88e81f1d62dc4aecb51ef3cec
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent edcd9db1
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -115,24 +115,6 @@ struct cpufreq_cooling_device {
static DEFINE_MUTEX(cooling_list_lock);
static LIST_HEAD(cpufreq_cdev_list);

static struct cpumask cpus_in_max_cooling_level;
static BLOCKING_NOTIFIER_HEAD(cpu_max_cooling_level_notifer);

void cpu_cooling_max_level_notifier_register(struct notifier_block *n)
{
	blocking_notifier_chain_register(&cpu_max_cooling_level_notifer, n);
}

void cpu_cooling_max_level_notifier_unregister(struct notifier_block *n)
{
	blocking_notifier_chain_unregister(&cpu_max_cooling_level_notifer, n);
}

const struct cpumask *cpu_cooling_get_max_level_cpumask(void)
{
	return &cpus_in_max_cooling_level;
}

/* Below code defines functions to be used for cpufreq as cooling device */

/**
+25 −0
Original line number Diff line number Diff line
@@ -27,6 +27,24 @@ static atomic_t in_suspend;
static struct cpumask cpus_pending_online;
static struct cpumask cpus_isolated_by_thermal;

static struct cpumask cpus_in_max_cooling_level;
static BLOCKING_NOTIFIER_HEAD(cpu_max_cooling_level_notifer);

void cpu_cooling_max_level_notifier_register(struct notifier_block *n)
{
	blocking_notifier_chain_register(&cpu_max_cooling_level_notifer, n);
}

void cpu_cooling_max_level_notifier_unregister(struct notifier_block *n)
{
	blocking_notifier_chain_unregister(&cpu_max_cooling_level_notifer, n);
}

const struct cpumask *cpu_cooling_get_max_level_cpumask(void)
{
	return &cpus_in_max_cooling_level;
}

static int cpu_isolate_pm_notify(struct notifier_block *nb,
				unsigned long mode, void *_unused)
{
@@ -168,6 +186,9 @@ static int cpu_isolate_set_cur_state(struct thermal_cooling_device *cdev,
				cpumask_clear_cpu(cpu,
					&cpus_isolated_by_thermal);
		}
		cpumask_set_cpu(cpu, &cpus_in_max_cooling_level);
		blocking_notifier_call_chain(&cpu_max_cooling_level_notifer,
						1, (void *)(long)cpu);
	} else {
		if (cpumask_test_and_clear_cpu(cpu, &cpus_pending_online)) {
			cpu_dev = get_cpu_device(cpu);
@@ -180,6 +201,9 @@ static int cpu_isolate_set_cur_state(struct thermal_cooling_device *cdev,
			&cpus_isolated_by_thermal)) {
			sched_unisolate_cpu(cpu);
		}
		cpumask_clear_cpu(cpu, &cpus_in_max_cooling_level);
		blocking_notifier_call_chain(&cpu_max_cooling_level_notifer,
						0, (void *)(long)cpu);
	}
	mutex_unlock(&cpu_isolate_lock);

@@ -294,6 +318,7 @@ static int cpu_isolate_probe(struct platform_device *pdev)
	if (ret < 0)
		return ret;
	register_pm_notifier(&cpu_isolate_pm_nb);
	cpumask_clear(&cpus_in_max_cooling_level);
	ret = 0;

	return ret;
+20 −3
Original line number Diff line number Diff line
@@ -54,9 +54,6 @@ cpufreq_platform_cooling_register(struct cpufreq_policy *policy,
 */
void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);

extern void cpu_cooling_max_level_notifier_register(struct notifier_block *n);
extern void cpu_cooling_max_level_notifier_unregister(struct notifier_block *n);
extern const struct cpumask *cpu_cooling_get_max_level_cpumask(void);
#else /* !CONFIG_CPU_THERMAL */
static inline struct thermal_cooling_device *
cpufreq_cooling_register(struct cpufreq_policy *policy)
@@ -93,4 +90,24 @@ cpufreq_platform_cooling_register(struct cpufreq_policy *policy,
}
#endif /* defined(CONFIG_THERMAL_OF) && defined(CONFIG_CPU_THERMAL) */

#ifdef CONFIG_QTI_CPU_ISOLATE_COOLING_DEVICE
extern void cpu_cooling_max_level_notifier_register(struct notifier_block *n);
extern void cpu_cooling_max_level_notifier_unregister(struct notifier_block *n);
extern const struct cpumask *cpu_cooling_get_max_level_cpumask(void);
#else
static inline
void cpu_cooling_max_level_notifier_register(struct notifier_block *n)
{
}

static inline
void cpu_cooling_max_level_notifier_unregister(struct notifier_block *n)
{
}

static inline const struct cpumask *cpu_cooling_get_max_level_cpumask(void)
{
	return cpu_none_mask;
}
#endif /* CONFIG_QTI_CPU_ISOLATE_COOLING_DEVICE */
#endif /* __CPU_COOLING_H__ */