PM / EM: Fix debugfs entry creation

recent changes in debugfs dont allow to create directories till fs_init
call level, but some cpu clock drivers populate OPP table in prior init
call levels, the energy model debugfs population called from the OPP
framework, before debugfs initialization. This breaks energy model
population in debugfs.

Fix it by not allowing energy model population prior to debugfs init call,
and populate debugfs entries, if power domains already created.

Change-Id: I2fb747b2c033fa83d362fea1ff815a628448b00f
Signed-off-by: Lingutla Chandrasekhar <quic_lingutla@quicinc.com>
Signed-off-by: Srinivasarao Pathipati <quic_spathi@quicinc.com>
This commit is contained in:
Lingutla Chandrasekhar 2021-10-18 13:17:57 +05:30 • committed by Srinivasarao Pathipati
commit 362ed223ec

View file

@ -55,6 +55,11 @@ static void em_debug_create_pd(struct em_perf_domain *pd, int cpu)
char name[8];
int i;
if (!rootdir) {
pr_err("Power domains created prior to em_debug_init\n");
return;
}
snprintf(name, sizeof(name), "pd%d", cpu);
/* Create the directory of the performance domain */
@ -69,9 +74,34 @@ static void em_debug_create_pd(struct em_perf_domain *pd, int cpu)
static int __init em_debug_init(void)
{
int cpu;
struct em_perf_domain *pd;
cpumask_t span;
cpumask_copy(&span, cpu_possible_mask);
/* Create /sys/kernel/debug/energy_model directory */
rootdir = debugfs_create_dir("energy_model", NULL);
for_each_cpu(cpu, &span) {
char name[8];
pd = em_cpu_get(cpu);
if (!pd) {
pr_info("Power domains not created yet\n");
break;
}
snprintf(name, sizeof(name), "pd%d", cpu);
if (debugfs_lookup(name, rootdir)) {
pr_info("Power domains already created\n");
break;
}
em_debug_create_pd(pd, cpu);
cpumask_andnot(&span, &span, to_cpumask(pd->cpus));
}
return 0;
}
fs_initcall(em_debug_init);