pm: Fix cpus active count
Only set a cpu as active (on pm subsystem) when the cpu is effectively
initialized. We cannot assume on pm subsystem that all cpus were
initialized since when the option CONFIG_SMP_BOOT_DELAY is used cpus are
initialized on demand by the application.
Note that once cpus are properly initialized the subystem is able to track
their status.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
diff --git a/kernel/init.c b/kernel/init.c
index cd08e26..9c4cbce 100644
--- a/kernel/init.c
+++ b/kernel/init.c
@@ -45,6 +45,9 @@
__pinned_bss
struct z_kernel _kernel;
+__pinned_bss
+atomic_t _cpus_active;
+
/* init/main and idle threads */
K_THREAD_PINNED_STACK_DEFINE(z_main_stack, CONFIG_MAIN_STACK_SIZE);
struct k_thread z_main_thread;
@@ -395,6 +398,12 @@
_kernel.cpus[id].usage.track_usage =
CONFIG_SCHED_THREAD_USAGE_AUTO_ENABLE;
#endif
+
+ /*
+ * Increment number of CPUs active. The pm subsystem
+ * will keep track of this from here.
+ */
+ atomic_inc(&_cpus_active);
}
/**