Skip to content

Commit 03a69ac

Browse files
committed
audio: base_fw: mark functions __cold
The base firmware code is never executed on hot paths, mark it all as "cold." Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 1acfa0b commit 03a69ac

2 files changed

Lines changed: 115 additions & 72 deletions

File tree

src/audio/base_fw.c

Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ DECLARE_TR_CTX(basefw_comp_tr, SOF_UUID(basefw_uuid), LOG_LEVEL_INFO);
4444
static struct ipc4_system_time_info global_system_time_info;
4545
static uint64_t global_cycle_delta;
4646

47-
static int basefw_config(uint32_t *data_offset, char *data)
47+
__cold static int basefw_config(uint32_t *data_offset, char *data)
4848
{
4949
uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD};
5050
struct sof_tlv *tuple = (struct sof_tlv *)data;
5151
struct ipc4_scheduler_config sche_cfg;
5252
uint32_t plat_data_offset = 0;
5353
uint32_t log_bytes_size = 0;
5454

55+
assert_can_be_cold();
56+
5557
tlv_value_set(tuple, IPC4_FW_VERSION_FW_CFG, sizeof(version), version);
5658

5759
tuple = tlv_next(tuple);
@@ -130,11 +132,13 @@ static int basefw_config(uint32_t *data_offset, char *data)
130132
return IPC4_SUCCESS;
131133
}
132134

133-
static int basefw_hw_config(uint32_t *data_offset, char *data)
135+
__cold static int basefw_hw_config(uint32_t *data_offset, char *data)
134136
{
135137
struct sof_tlv *tuple = (struct sof_tlv *)data;
136138
uint32_t plat_data_offset = 0;
137139

140+
assert_can_be_cold();
141+
138142
tlv_value_uint32_set(tuple, IPC4_CAVS_VER_HW_CFG, HW_CFG_VERSION);
139143

140144
tuple = tlv_next(tuple);
@@ -154,27 +158,29 @@ static int basefw_hw_config(uint32_t *data_offset, char *data)
154158
return IPC4_SUCCESS;
155159
}
156160

157-
struct ipc4_system_time_info *basefw_get_system_time_info(void)
161+
__cold struct ipc4_system_time_info *basefw_get_system_time_info(void)
158162
{
163+
assert_can_be_cold();
164+
159165
return &global_system_time_info;
160166
}
161167

168+
/* Cannot be cold - this function is called from the logger per log_set_timestamp_func() below */
162169
static log_timestamp_t basefw_get_timestamp(void)
163170
{
164171
return sof_cycle_get_64() + global_cycle_delta;
165172
}
166173

167-
static uint32_t basefw_set_system_time(uint32_t param_id,
168-
bool first_block,
169-
bool last_block,
170-
uint32_t data_offset,
171-
const char *data)
174+
__cold static uint32_t basefw_set_system_time(uint32_t param_id, bool first_block, bool last_block,
175+
uint32_t data_offset, const char *data)
172176
{
173177
uint64_t dsp_time;
174178
uint64_t dsp_cycle;
175179
uint64_t host_time;
176180
uint64_t host_cycle;
177181

182+
assert_can_be_cold();
183+
178184
if (!(first_block && last_block))
179185
return IPC4_INVALID_REQUEST;
180186

@@ -203,21 +209,23 @@ static uint32_t basefw_set_system_time(uint32_t param_id,
203209
return IPC4_SUCCESS;
204210
}
205211

206-
static uint32_t basefw_get_system_time(uint32_t *data_offset, char *data)
212+
__cold static uint32_t basefw_get_system_time(uint32_t *data_offset, char *data)
207213
{
208214
struct ipc4_system_time *system_time = (struct ipc4_system_time *)data;
209215

216+
assert_can_be_cold();
217+
210218
system_time->val_l = global_system_time_info.host_time.val_l;
211219
system_time->val_u = global_system_time_info.host_time.val_u;
212220
*data_offset = sizeof(struct ipc4_system_time);
213221
return IPC4_SUCCESS;
214222
}
215223

216-
static int basefw_register_kcps(bool first_block,
217-
bool last_block,
218-
uint32_t data_offset_or_size,
219-
const char *data)
224+
__cold static int basefw_register_kcps(bool first_block, bool last_block,
225+
uint32_t data_offset_or_size, const char *data)
220226
{
227+
assert_can_be_cold();
228+
221229
if (!(first_block && last_block))
222230
return IPC4_ERROR_INVALID_PARAM;
223231

@@ -230,8 +238,10 @@ static int basefw_register_kcps(bool first_block,
230238
return IPC4_SUCCESS;
231239
}
232240

233-
static int basefw_kcps_allocation_request(struct ipc4_resource_kcps *request)
241+
__cold static int basefw_kcps_allocation_request(struct ipc4_resource_kcps *request)
234242
{
243+
assert_can_be_cold();
244+
235245
#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
236246
if (core_kcps_adjust(request->core_id, request->kcps))
237247
return IPC4_ERROR_INVALID_PARAM;
@@ -240,13 +250,13 @@ static int basefw_kcps_allocation_request(struct ipc4_resource_kcps *request)
240250
return IPC4_SUCCESS;
241251
}
242252

243-
static int basefw_resource_allocation_request(bool first_block,
244-
bool last_block,
245-
uint32_t data_offset_or_size,
246-
const char *data)
253+
__cold static int basefw_resource_allocation_request(bool first_block, bool last_block,
254+
uint32_t data_offset_or_size, const char *data)
247255
{
248256
struct ipc4_resource_request *request;
249257

258+
assert_can_be_cold();
259+
250260
if (!(first_block && last_block))
251261
return IPC4_ERROR_INVALID_PARAM;
252262

@@ -262,8 +272,10 @@ static int basefw_resource_allocation_request(bool first_block,
262272
}
263273
}
264274

265-
static int basefw_power_state_info_get(uint32_t *data_offset, char *data)
275+
__cold static int basefw_power_state_info_get(uint32_t *data_offset, char *data)
266276
{
277+
assert_can_be_cold();
278+
267279
#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
268280
struct sof_tlv *tuple = (struct sof_tlv *)data;
269281
uint32_t core_kcps[CONFIG_CORE_COUNT] = {0};
@@ -286,8 +298,10 @@ static int basefw_power_state_info_get(uint32_t *data_offset, char *data)
286298
#endif
287299
}
288300

289-
static int basefw_libraries_info_get(uint32_t *data_offset, char *data)
301+
__cold static int basefw_libraries_info_get(uint32_t *data_offset, char *data)
290302
{
303+
assert_can_be_cold();
304+
291305
if (sizeof(struct ipc4_libraries_info) +
292306
LIB_MANAGER_MAX_LIBS * sizeof(struct ipc4_library_props) >
293307
SOF_IPC_MSG_MAX_SIZE) {
@@ -337,15 +351,17 @@ static int basefw_libraries_info_get(uint32_t *data_offset, char *data)
337351
return IPC4_SUCCESS;
338352
}
339353

340-
static int basefw_modules_info_get(uint32_t *data_offset, char *data)
354+
__cold static int basefw_modules_info_get(uint32_t *data_offset, char *data)
341355
{
356+
assert_can_be_cold();
357+
342358
return basefw_vendor_modules_info_get(data_offset, data);
343359
}
344360

345-
int schedulers_info_get(uint32_t *data_off_size,
346-
char *data,
347-
uint32_t core_id)
361+
__cold int schedulers_info_get(uint32_t *data_off_size, char *data, uint32_t core_id)
348362
{
363+
assert_can_be_cold();
364+
349365
/* Check if the requested core_id is valid and within the number of configured cores */
350366
if (core_id >= CONFIG_CORE_COUNT)
351367
return IPC4_ERROR_INVALID_PARAM;
@@ -382,14 +398,16 @@ int schedulers_info_get(uint32_t *data_off_size,
382398
return IPC4_SUCCESS;
383399
}
384400

385-
static int basefw_pipeline_list_info_get(uint32_t *data_offset, char *data)
401+
__cold static int basefw_pipeline_list_info_get(uint32_t *data_offset, char *data)
386402
{
387403
struct ipc4_pipeline_set_state_data *ppl_data = (struct ipc4_pipeline_set_state_data *)data;
388404

389405
struct ipc *ipc = ipc_get();
390406
struct ipc_comp_dev *ipc_pipe;
391407
const struct ipc4_pipeline_set_state_data *pipeline_data;
392408

409+
assert_can_be_cold();
410+
393411
pipeline_data = ipc4_get_pipeline_data_wrapper();
394412
ppl_data->pipelines_count = 0;
395413

@@ -407,8 +425,10 @@ static int basefw_pipeline_list_info_get(uint32_t *data_offset, char *data)
407425
return IPC4_SUCCESS;
408426
}
409427

410-
int set_perf_meas_state(const char *data)
428+
__cold int set_perf_meas_state(const char *data)
411429
{
430+
assert_can_be_cold();
431+
412432
#ifdef CONFIG_SOF_TELEMETRY
413433
enum ipc4_perf_measurements_state_set state = *data;
414434

@@ -437,8 +457,10 @@ int set_perf_meas_state(const char *data)
437457
return IPC4_SUCCESS;
438458
}
439459

440-
static int extended_global_perf_data_get(uint32_t *data_off_size, char *data)
460+
__cold static int extended_global_perf_data_get(uint32_t *data_off_size, char *data)
441461
{
462+
assert_can_be_cold();
463+
442464
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
443465
int ret;
444466
struct extended_global_perf_data *perf_data = (struct extended_global_perf_data *)data;
@@ -455,8 +477,10 @@ static int extended_global_perf_data_get(uint32_t *data_off_size, char *data)
455477
#endif
456478
}
457479

458-
static int global_perf_data_get(uint32_t *data_off_size, char *data)
480+
__cold static int global_perf_data_get(uint32_t *data_off_size, char *data)
459481
{
482+
assert_can_be_cold();
483+
460484
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
461485
int ret;
462486
struct global_perf_data *perf_data = (struct global_perf_data *)data;
@@ -473,8 +497,10 @@ static int global_perf_data_get(uint32_t *data_off_size, char *data)
473497
#endif
474498
}
475499

476-
static int io_global_perf_state_get(uint32_t *data_off_size, char *data)
500+
__cold static int io_global_perf_state_get(uint32_t *data_off_size, char *data)
477501
{
502+
assert_can_be_cold();
503+
478504
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
479505
*data = io_perf_monitor_get_state();
480506
*data_off_size = sizeof(enum ipc4_perf_measurements_state_set);
@@ -485,8 +511,10 @@ static int io_global_perf_state_get(uint32_t *data_off_size, char *data)
485511
#endif
486512
}
487513

488-
static int io_global_perf_data_get(uint32_t *data_off_size, char *data)
514+
__cold static int io_global_perf_data_get(uint32_t *data_off_size, char *data)
489515
{
516+
assert_can_be_cold();
517+
490518
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
491519
int ret;
492520
struct io_global_perf_data *perf_data = (struct io_global_perf_data *)data;
@@ -503,25 +531,26 @@ static int io_global_perf_data_get(uint32_t *data_off_size, char *data)
503531
#endif
504532
}
505533

506-
static int io_perf_monitor_state_set(const char *data)
534+
__cold static int io_perf_monitor_state_set(const char *data)
507535
{
536+
assert_can_be_cold();
537+
508538
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
509539
return io_perf_monitor_set_state((enum ipc4_perf_measurements_state_set)*data);
510540
#else
511541
return IPC4_UNAVAILABLE;
512542
#endif
513543
}
514544

515-
static int basefw_get_large_config(struct comp_dev *dev,
516-
uint32_t param_id,
517-
bool first_block,
518-
bool last_block,
519-
uint32_t *data_offset,
520-
char *data)
545+
__cold static int basefw_get_large_config(struct comp_dev *dev, uint32_t param_id,
546+
bool first_block, bool last_block,
547+
uint32_t *data_offset, char *data)
521548
{
522549
/* We can use extended param id for both extended and standard param id */
523550
union ipc4_extended_param_id extended_param_id;
524551

552+
assert_can_be_cold();
553+
525554
extended_param_id.full = param_id;
526555

527556
switch (extended_param_id.part.parameter_type) {
@@ -584,15 +613,15 @@ static int basefw_get_large_config(struct comp_dev *dev,
584613
* @param data Pointer to the data buffer containing the DMA Control message.
585614
* @return 0 on success, error code on failure.
586615
*/
587-
static int basefw_dma_control(bool first_block,
588-
bool last_block,
589-
uint32_t data_offset,
590-
const char *data)
616+
__cold static int basefw_dma_control(bool first_block, bool last_block, uint32_t data_offset,
617+
const char *data)
591618
{
592619
struct ipc4_dma_control *dma_control;
593620
size_t data_size;
594621
int ret;
595622

623+
assert_can_be_cold();
624+
596625
/* Ensure that the message is atomic and contains all necessary information */
597626
if (!first_block || !last_block) {
598627
tr_err(&ipc_tr, "Non-atomic DMA Control message received");
@@ -619,13 +648,12 @@ static int basefw_dma_control(bool first_block,
619648
return IPC4_SUCCESS;
620649
}
621650

622-
static int basefw_set_large_config(struct comp_dev *dev,
623-
uint32_t param_id,
624-
bool first_block,
625-
bool last_block,
626-
uint32_t data_offset,
627-
const char *data)
651+
__cold static int basefw_set_large_config(struct comp_dev *dev, uint32_t param_id,
652+
bool first_block, bool last_block,
653+
uint32_t data_offset, const char *data)
628654
{
655+
assert_can_be_cold();
656+
629657
switch (param_id) {
630658
case IPC4_DMA_CONTROL:
631659
return basefw_dma_control(first_block, last_block, data_offset, data);

0 commit comments

Comments
 (0)