Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/audio/mic_privacy_manager/mic_privacy_manager_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sof/audio/audio_stream.h>
#include <sof/audio/buffer.h>
#include <sof/audio/mic_privacy_manager.h>
#include <sof/lib/memory.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using "treewide: " seems a bit random here. It's touching common code, Intel specific code, platform code, all in same commit but it's not doing a particular change to all code.

Maybe refer to init functions in commit title, "treewide: convert more init functions to cold" ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i it is a rather particular change: I just checked all SOF functions called from primary and secondary core initialisation functions in init.c and platform.c. Those calling functions themselves are __cold() so other initialisation functions, called only from them, can be cold too

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh that's more logic, can you put that in the title and commit somehow? then the treewide commit makes more sense


const struct device *mic_priv_dev;

Expand Down Expand Up @@ -88,10 +89,12 @@ void mic_privacy_enable_dmic_irq(bool enable_irq)
}
}

int mic_privacy_manager_init(void)
__cold int mic_privacy_manager_init(void)
{
mic_priv_dev = DEVICE_DT_GET(DT_NODELABEL(mic_privacy));

assert_can_be_cold();

if (!mic_priv_dev)
return -EINVAL;

Expand Down
5 changes: 4 additions & 1 deletion src/debug/telemetry/performance_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sof/debug/telemetry/performance_monitor.h>
#include <sof/debug/telemetry/telemetry.h>
#include <sof/lib/cpu.h>
#include <sof/lib/memory.h>
#include <sof/lib_manager.h>

#include <zephyr/sys/bitarray.h>
Expand Down Expand Up @@ -427,11 +428,13 @@ SYS_BITARRAY_DEFINE_STATIC(io_performance_data_bit_array, PERFORMANCE_DATA_ENTRI
static struct io_perf_monitor_ctx perf_monitor_ctx;
static struct io_perf_data_item io_perf_data_items[IO_PERFORMANCE_MAX_ENTRIES];

int io_perf_monitor_init(void)
__cold int io_perf_monitor_init(void)
{
int ret;
struct io_perf_monitor_ctx *self = &perf_monitor_ctx;

assert_can_be_cold();

k_spinlock_init(&self->lock);
k_spinlock_key_t key = k_spin_lock(&self->lock);

Expand Down
5 changes: 4 additions & 1 deletion src/idc/idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <rtos/alloc.h>
#include <rtos/clk.h>
#include <sof/lib/cpu.h>
#include <sof/lib/memory.h>
#include <sof/lib/notifier.h>
#include <sof/lib/pm_runtime.h>
#include <sof/lib/uuid.h>
Expand Down Expand Up @@ -419,10 +420,12 @@ void idc_cmd(struct idc_msg *msg)
}

/* Runs on each CPU */
int idc_init(void)
__cold int idc_init(void)
{
struct idc **idc = idc_get();

assert_can_be_cold();

tr_dbg(&idc_tr, "entry");

/* initialize idc data */
Expand Down
4 changes: 3 additions & 1 deletion src/idc/zephyr_idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ int idc_send_msg(struct idc_msg *msg, uint32_t mode)
return ret;
}

void idc_init_thread(void)
__cold void idc_init_thread(void)
{
char thread_name[] = "idc_p4wq0";
int cpu = cpu_get_id();

assert_can_be_cold();

k_p4wq_enable_static_thread(q_zephyr_idc + cpu,
_p4threads_q_zephyr_idc + cpu, BIT(cpu));

Expand Down
6 changes: 6 additions & 0 deletions src/init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ __cold int secondary_core_init(struct sof *sof)
int err;
struct ll_schedule_domain *dma_domain;

assert_can_be_cold();

/* check whether we are in a cold boot process or not (e.g. D0->D0ix
* flow when primary core disables all secondary cores). If not, we do
* not have allocate basic structures like e.g. schedulers, notifier,
Expand Down Expand Up @@ -163,6 +165,8 @@ __cold int secondary_core_init(struct sof *sof)

__cold static void print_version_banner(void)
{
assert_can_be_cold();

/*
* Non-Zephyr builds emit the version banner in DMA-trace
* init and this is done at a later time as otherwise the
Expand Down Expand Up @@ -193,6 +197,8 @@ static log_timestamp_t default_get_timestamp(void)

__cold static int primary_core_init(int argc, char *argv[], struct sof *sof)
{
assert_can_be_cold();

/* setup context */
sof->argc = argc;
sof->argv = argv;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ static enum task_state validate(void *data)
return SOF_TASK_STATE_RESCHEDULE;
}

void sa_init(struct sof *sof, uint64_t timeout)
__cold void sa_init(struct sof *sof, uint64_t timeout)
{
uint64_t ticks;

assert_can_be_cold();

if (timeout > UINT_MAX)
tr_warn(&sa_tr, "timeout > %u", UINT_MAX);
else
Expand Down
5 changes: 3 additions & 2 deletions src/lib/ams.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <sof/ipc/topology.h>
#include <rtos/idc.h>
#include <rtos/alloc.h>
#include <sof/lib/memory.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down Expand Up @@ -578,13 +577,15 @@ static int ams_create_shared_context(struct ams_shared_context *ctx)
return 0;
}

int ams_init(void)
__cold int ams_init(void)
{
struct ams_shared_context *ams_shared_ctx;
struct async_message_service **ams = arch_ams_get();
struct sof *sof;
int ret = 0;

assert_can_be_cold();

*ams = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(**ams));
if (!*ams)
Expand Down
5 changes: 4 additions & 1 deletion src/lib/notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ void notifier_event(const void *caller, enum notify_id type, uint32_t core_mask,
}
}

void init_system_notify(struct sof *sof)
__cold void init_system_notify(struct sof *sof)
{
struct notify **notify = arch_notify_get();
int i;

assert_can_be_cold();

*notify = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(**notify));
if (!*notify) {
Expand Down
5 changes: 4 additions & 1 deletion src/platform/intel/ace/lib/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Author: Adrian Warecki <adrian.warecki@intel.com>
*/

#include <sof/lib/memory.h>
#include <sof/lib/uuid.h>
#include <rtos/idc.h>
#include <sof/schedule/ll_schedule_domain.h>
Expand Down Expand Up @@ -72,14 +73,16 @@ static void watchdog_timeout(const struct device *dev, int core)
watchdog_secondary_core_action_on_timeout();
}

void watchdog_init(void)
__cold void watchdog_init(void)
{
int i, ret;
const struct wdt_timeout_cfg watchdog_config = {
.window.max = LL_WATCHDOG_TIMEOUT_US / 1000,
.callback = watchdog_timeout,
};

assert_can_be_cold();

secondary_timeout_ipc.tx_data = NULL;
secondary_timeout_ipc.tx_size = 0;
list_init(&secondary_timeout_ipc.list);
Expand Down
4 changes: 4 additions & 0 deletions src/platform/intel/ace/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ __cold int platform_boot_complete(uint32_t boot_message)
{
struct ipc_cmd_hdr header;

assert_can_be_cold();

/* get any IPC specific boot message and optional data */
ipc_boot_complete_msg(&header, 0);
header.pri |= boot_message;
Expand Down Expand Up @@ -92,6 +94,8 @@ __cold int platform_init(struct sof *sof)
{
int ret;

assert_can_be_cold();

trace_point(TRACE_BOOT_PLATFORM_CLOCK);
platform_clock_init(sof);

Expand Down
6 changes: 5 additions & 1 deletion src/schedule/zephyr_dp_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <zephyr/sys_clock.h>
#include <zephyr/sys/sem.h>
#include <zephyr/sys/mutex.h>
#include <sof/lib/memory.h>
#include <sof/lib/notifier.h>
#include <ipc4/base_fw.h>

Expand Down Expand Up @@ -346,9 +347,12 @@ static struct scheduler_ops schedule_dp_ops = {
.schedule_task_free = scheduler_dp_task_free,
};

int scheduler_dp_init(void)
__cold int scheduler_dp_init(void)
{
int ret;

assert_can_be_cold();

struct scheduler_dp_data *dp_sch = rzalloc(SOF_MEM_FLAG_KERNEL,
sizeof(struct scheduler_dp_data));
if (!dp_sch)
Expand Down
5 changes: 4 additions & 1 deletion src/schedule/zephyr_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <rtos/symbol.h>
#include <sof/audio/component.h>
#include <rtos/interrupt.h>
#include <sof/lib/memory.h>
#include <sof/lib/notifier.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/schedule/schedule.h>
Expand Down Expand Up @@ -604,13 +605,15 @@ EXPORT_SYMBOL(zephyr_ll_task_init);

/* TODO: low-power mode clock support */
/* Runs on each core during initialisation with the same domain argument */
int zephyr_ll_scheduler_init(struct ll_schedule_domain *domain)
__cold int zephyr_ll_scheduler_init(struct ll_schedule_domain *domain)
{
struct zephyr_ll *sch;
int core = cpu_get_id();
struct k_heap *heap = sof_sys_heap_get();
int flags = SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT;

assert_can_be_cold();

#if CONFIG_SOF_USERSPACE_LL
heap = zephyr_ll_user_heap();
flags = SOF_MEM_FLAG_USER;
Expand Down
5 changes: 4 additions & 1 deletion src/schedule/zephyr_twb_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <rtos/task.h>
#include <stdint.h>
#include <sof/lib/memory.h>
#include <sof/lib/uuid.h>
#include <sof/schedule/schedule.h>
#include <sof/schedule/ll_schedule.h>
Expand Down Expand Up @@ -348,12 +349,14 @@ static struct scheduler_ops schedule_twb_ops = {
.schedule_task_free = scheduler_twb_task_free,
};

int scheduler_twb_init(void)
__cold int scheduler_twb_init(void)
{
struct scheduler_twb_data *twb_sch = rzalloc(SOF_MEM_FLAG_KERNEL,
sizeof(struct scheduler_twb_data));
int ret;

assert_can_be_cold();

if (!twb_sch)
return -ENOMEM;

Expand Down
5 changes: 4 additions & 1 deletion zephyr/edf_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Author: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>

#include <sof/audio/component.h>
#include <sof/lib/memory.h>
#include <rtos/alloc.h>
#include <rtos/task.h>
#include <stdint.h>
Expand Down Expand Up @@ -99,10 +100,12 @@ static struct scheduler_ops schedule_edf_ops = {
.schedule_task_free = schedule_edf_task_free,
};

int scheduler_init_edf(void)
__cold int scheduler_init_edf(void)
{
struct k_thread *thread = &edf_workq.thread;

assert_can_be_cold();

scheduler_init(SOF_SCHEDULE_EDF, &schedule_edf_ops, NULL);

k_work_queue_start(&edf_workq,
Expand Down
4 changes: 3 additions & 1 deletion zephyr/lib/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,12 @@ const struct dma_info lib_dma = {
};

/* Initialize all platform DMAC's */
int dmac_init(struct sof *sof)
__cold int dmac_init(struct sof *sof)
{
int i;

assert_can_be_cold();

sof->dma_info = &lib_dma;

/* early lock initialization for ref counting */
Expand Down
Loading