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

Commit 52cb67eb authored by Patrick Bellasi's avatar Patrick Bellasi Committed by Dmitry Shmidt
Browse files

ANDROID: sched/tune: use a single initialisation function



With the introduction of initialization function required to compute the
energy normalization constants from DTB at boot time, we have now a
late_initcall which is already used by SchedTune.

This patch consolidate within that function the other initialization
bits which was previously deferred to the first CGroup creation.

Signed-off-by: default avatarPatrick Bellasi <patrick.bellasi@arm.com>
[jstultz: fwdported to 4.4]
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarAndres Oportus <andresoportus@google.com>
parent 2ed513e7
Loading
Loading
Loading
Loading
+26 −24
Original line number Diff line number Diff line
@@ -410,8 +410,6 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft,
	    s64 boost)
{
	struct schedtune *st = css_st(css);
	unsigned threshold_idx;
	int boost_pct;

	if (boost < -100 || boost > 100)
		return -EINVAL;
@@ -456,33 +454,14 @@ schedtune_boostgroup_init(struct schedtune *st)
	return 0;
}

static int
schedtune_init(void)
{
	struct boost_groups *bg;
	int cpu;

	/* Initialize the per CPU boost groups */
	for_each_possible_cpu(cpu) {
		bg = &per_cpu(cpu_boost_groups, cpu);
		memset(bg, 0, sizeof(struct boost_groups));
	}

	pr_info("  schedtune configured to support %d boost groups\n",
		BOOSTGROUPS_COUNT);
	return 0;
}

static struct cgroup_subsys_state *
schedtune_css_alloc(struct cgroup_subsys_state *parent_css)
{
	struct schedtune *st;
	int idx;

	if (!parent_css) {
		schedtune_init();
	if (!parent_css)
		return &root_schedtune.css;
	}

	/* Allow only single level hierachies */
	if (parent_css != &root_schedtune.css) {
@@ -543,6 +522,22 @@ struct cgroup_subsys schedtune_cgrp_subsys = {
	.early_init	= 1,
};

static inline void
schedtune_init_cgroups(void)
{
	struct boost_groups *bg;
	int cpu;

	/* Initialize the per CPU boost groups */
	for_each_possible_cpu(cpu) {
		bg = &per_cpu(cpu_boost_groups, cpu);
		memset(bg, 0, sizeof(struct boost_groups));
	}

	pr_info("schedtune: configured to support %d boost groups\n",
		BOOSTGROUPS_COUNT);
}

#else /* CONFIG_CGROUP_SCHEDTUNE */

int
@@ -690,7 +685,7 @@ schedtune_add_cluster_nrg(
 * that bind the EM to the topology information.
 */
static int
schedtune_init_late(void)
schedtune_init(void)
{
	struct target_nrg *ste = &schedtune_target_nrg;
	unsigned long delta_pwr = 0;
@@ -730,10 +725,17 @@ schedtune_init_late(void)
		ste->rdiv.m, ste->rdiv.sh1, ste->rdiv.sh2);

	schedtune_test_nrg(delta_pwr);

#ifdef CONFIG_CGROUP_SCHEDTUNE
	schedtune_init_cgroups();
#else
	pr_info("schedtune: configured to support global boosting only\n");
#endif

	return 0;

nodata:
	rcu_read_unlock();
	return -EINVAL;
}
late_initcall(schedtune_init_late);
late_initcall(schedtune_init);