Skip to content

Commit d9d9971

Browse files
committed
tree-wide: make more functions "cold," add missing memory.h
Mark more functions, run only on non-time critical paths, as "cold." Add memory.h where missing and the cold-safety assertion. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent c9b4f12 commit d9d9971

13 files changed

Lines changed: 52 additions & 12 deletions

File tree

src/audio/mic_privacy_manager/mic_privacy_manager_intel.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sof/audio/audio_stream.h>
1111
#include <sof/audio/buffer.h>
1212
#include <sof/audio/mic_privacy_manager.h>
13+
#include <sof/lib/memory.h>
1314

1415
const struct device *mic_priv_dev;
1516

@@ -88,10 +89,12 @@ void mic_privacy_enable_dmic_irq(bool enable_irq)
8889
}
8990
}
9091

91-
int mic_privacy_manager_init(void)
92+
__cold int mic_privacy_manager_init(void)
9293
{
9394
mic_priv_dev = DEVICE_DT_GET(DT_NODELABEL(mic_privacy));
9495

96+
assert_can_be_cold();
97+
9598
if (!mic_priv_dev)
9699
return -EINVAL;
97100

src/debug/telemetry/performance_monitor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <sof/debug/telemetry/performance_monitor.h>
99
#include <sof/debug/telemetry/telemetry.h>
1010
#include <sof/lib/cpu.h>
11+
#include <sof/lib/memory.h>
1112
#include <sof/lib_manager.h>
1213

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

430-
int io_perf_monitor_init(void)
431+
__cold int io_perf_monitor_init(void)
431432
{
432433
int ret;
433434
struct io_perf_monitor_ctx *self = &perf_monitor_ctx;
434435

436+
assert_can_be_cold();
437+
435438
k_spinlock_init(&self->lock);
436439
k_spinlock_key_t key = k_spin_lock(&self->lock);
437440

src/init/init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ __cold int secondary_core_init(struct sof *sof)
110110
int err;
111111
struct ll_schedule_domain *dma_domain;
112112

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

164166
__cold static void print_version_banner(void)
165167
{
168+
assert_can_be_cold();
169+
166170
/*
167171
* Non-Zephyr builds emit the version banner in DMA-trace
168172
* init and this is done at a later time as otherwise the
@@ -193,6 +197,8 @@ static log_timestamp_t default_get_timestamp(void)
193197

194198
__cold static int primary_core_init(int argc, char *argv[], struct sof *sof)
195199
{
200+
assert_can_be_cold();
201+
196202
/* setup context */
197203
sof->argc = argc;
198204
sof->argv = argv;

src/lib/agent.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ static enum task_state validate(void *data)
9393
return SOF_TASK_STATE_RESCHEDULE;
9494
}
9595

96-
void sa_init(struct sof *sof, uint64_t timeout)
96+
__cold void sa_init(struct sof *sof, uint64_t timeout)
9797
{
9898
uint64_t ticks;
9999

100+
assert_can_be_cold();
101+
100102
if (timeout > UINT_MAX)
101103
tr_warn(&sa_tr, "timeout > %u", UINT_MAX);
102104
else

src/lib/ams.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <sof/ipc/topology.h>
1717
#include <rtos/idc.h>
1818
#include <rtos/alloc.h>
19-
#include <sof/lib/memory.h>
2019
#include <errno.h>
2120
#include <stdbool.h>
2221
#include <stddef.h>
@@ -578,13 +577,15 @@ static int ams_create_shared_context(struct ams_shared_context *ctx)
578577
return 0;
579578
}
580579

581-
int ams_init(void)
580+
__cold int ams_init(void)
582581
{
583582
struct ams_shared_context *ams_shared_ctx;
584583
struct async_message_service **ams = arch_ams_get();
585584
struct sof *sof;
586585
int ret = 0;
587586

587+
assert_can_be_cold();
588+
588589
*ams = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
589590
sizeof(**ams));
590591
if (!*ams)

src/lib/notifier.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,13 @@ void notifier_event(const void *caller, enum notify_id type, uint32_t core_mask,
190190
}
191191
}
192192

193-
void init_system_notify(struct sof *sof)
193+
__cold void init_system_notify(struct sof *sof)
194194
{
195195
struct notify **notify = arch_notify_get();
196196
int i;
197+
198+
assert_can_be_cold();
199+
197200
*notify = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
198201
sizeof(**notify));
199202
if (!*notify) {

src/platform/intel/ace/lib/watchdog.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Author: Adrian Warecki <adrian.warecki@intel.com>
66
*/
77

8+
#include <sof/lib/memory.h>
89
#include <sof/lib/uuid.h>
910
#include <rtos/idc.h>
1011
#include <sof/schedule/ll_schedule_domain.h>
@@ -72,14 +73,16 @@ static void watchdog_timeout(const struct device *dev, int core)
7273
watchdog_secondary_core_action_on_timeout();
7374
}
7475

75-
void watchdog_init(void)
76+
__cold void watchdog_init(void)
7677
{
7778
int i, ret;
7879
const struct wdt_timeout_cfg watchdog_config = {
7980
.window.max = LL_WATCHDOG_TIMEOUT_US / 1000,
8081
.callback = watchdog_timeout,
8182
};
8283

84+
assert_can_be_cold();
85+
8386
secondary_timeout_ipc.tx_data = NULL;
8487
secondary_timeout_ipc.tx_size = 0;
8588
list_init(&secondary_timeout_ipc.list);

src/platform/intel/ace/platform.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ __cold int platform_boot_complete(uint32_t boot_message)
6565
{
6666
struct ipc_cmd_hdr header;
6767

68+
assert_can_be_cold();
69+
6870
/* get any IPC specific boot message and optional data */
6971
ipc_boot_complete_msg(&header, 0);
7072
header.pri |= boot_message;
@@ -92,6 +94,8 @@ __cold int platform_init(struct sof *sof)
9294
{
9395
int ret;
9496

97+
assert_can_be_cold();
98+
9599
trace_point(TRACE_BOOT_PLATFORM_CLOCK);
96100
platform_clock_init(sof);
97101

src/schedule/zephyr_dp_schedule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <zephyr/sys_clock.h>
2222
#include <zephyr/sys/sem.h>
2323
#include <zephyr/sys/mutex.h>
24+
#include <sof/lib/memory.h>
2425
#include <sof/lib/notifier.h>
2526
#include <ipc4/base_fw.h>
2627

@@ -346,9 +347,12 @@ static struct scheduler_ops schedule_dp_ops = {
346347
.schedule_task_free = scheduler_dp_task_free,
347348
};
348349

349-
int scheduler_dp_init(void)
350+
__cold int scheduler_dp_init(void)
350351
{
351352
int ret;
353+
354+
assert_can_be_cold();
355+
352356
struct scheduler_dp_data *dp_sch = rzalloc(SOF_MEM_FLAG_KERNEL,
353357
sizeof(struct scheduler_dp_data));
354358
if (!dp_sch)

src/schedule/zephyr_ll.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <rtos/symbol.h>
1010
#include <sof/audio/component.h>
1111
#include <rtos/interrupt.h>
12+
#include <sof/lib/memory.h>
1213
#include <sof/lib/notifier.h>
1314
#include <sof/schedule/ll_schedule_domain.h>
1415
#include <sof/schedule/schedule.h>
@@ -604,13 +605,15 @@ EXPORT_SYMBOL(zephyr_ll_task_init);
604605

605606
/* TODO: low-power mode clock support */
606607
/* Runs on each core during initialisation with the same domain argument */
607-
int zephyr_ll_scheduler_init(struct ll_schedule_domain *domain)
608+
__cold int zephyr_ll_scheduler_init(struct ll_schedule_domain *domain)
608609
{
609610
struct zephyr_ll *sch;
610611
int core = cpu_get_id();
611612
struct k_heap *heap = sof_sys_heap_get();
612613
int flags = SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT;
613614

615+
assert_can_be_cold();
616+
614617
#if CONFIG_SOF_USERSPACE_LL
615618
heap = zephyr_ll_user_heap();
616619
flags = SOF_MEM_FLAG_USER;

0 commit comments

Comments
 (0)