Skip to content

Commit c73fb8c

Browse files
committed
audio: dai: mark non-critical code as "cold"
Add __cold qualifiers to IPC context functions. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 03a69ac commit c73fb8c

3 files changed

Lines changed: 105 additions & 44 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ static void dai_atomic_trigger(void *arg, enum notify_id type, void *data)
7676
}
7777

7878
/* Assign DAI to a group */
79-
int dai_assign_group(struct dai_data *dd, struct comp_dev *dev, uint32_t group_id)
79+
__cold int dai_assign_group(struct dai_data *dd, struct comp_dev *dev, uint32_t group_id)
8080
{
81+
assert_can_be_cold();
82+
8183
if (dd->group) {
8284
if (dd->group->group_id != group_id) {
8385
comp_err(dev, "DAI already in group %d, requested %d",
@@ -135,15 +137,17 @@ static int dai_trigger_op(struct dai *dai, int cmd, int direction)
135137
}
136138

137139
/* called from src/ipc/ipc3/handler.c and src/ipc/ipc4/dai.c */
138-
int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
139-
const void *spec_config)
140+
__cold int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
141+
const void *spec_config)
140142
{
141143
const struct device *dev = dai->dev;
142144
const struct sof_ipc_dai_config *sof_cfg = spec_config;
143145
struct dai_config cfg;
144146
const void *cfg_params;
145147
bool is_blob;
146148

149+
assert_can_be_cold();
150+
147151
cfg.dai_index = common_config->dai_index;
148152
is_blob = common_config->is_config_blob;
149153
cfg.format = sof_cfg->format;
@@ -193,25 +197,29 @@ int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
193197
}
194198

195199
/* called from ipc/ipc3/dai.c */
196-
int dai_get_handshake(struct dai *dai, int direction, int stream_id)
200+
__cold int dai_get_handshake(struct dai *dai, int direction, int stream_id)
197201
{
198202
k_spinlock_key_t key = k_spin_lock(&dai->lock);
199203
const struct dai_properties *props = dai_get_properties(dai->dev, direction,
200204
stream_id);
201205
int hs_id = props->dma_hs_id;
202206

207+
assert_can_be_cold();
208+
203209
k_spin_unlock(&dai->lock, key);
204210

205211
return hs_id;
206212
}
207213

208214
/* called from ipc/ipc3/dai.c and ipc/ipc4/dai.c */
209-
int dai_get_fifo_depth(struct dai *dai, int direction)
215+
__cold int dai_get_fifo_depth(struct dai *dai, int direction)
210216
{
211217
const struct dai_properties *props;
212218
k_spinlock_key_t key;
213219
int fifo_depth;
214220

221+
assert_can_be_cold();
222+
215223
if (!dai)
216224
return 0;
217225

@@ -223,24 +231,28 @@ int dai_get_fifo_depth(struct dai *dai, int direction)
223231
return fifo_depth;
224232
}
225233

226-
int dai_get_stream_id(struct dai *dai, int direction)
234+
__cold int dai_get_stream_id(struct dai *dai, int direction)
227235
{
228236
k_spinlock_key_t key = k_spin_lock(&dai->lock);
229237
const struct dai_properties *props = dai_get_properties(dai->dev, direction, 0);
230238
int stream_id = props->stream_id;
231239

240+
assert_can_be_cold();
241+
232242
k_spin_unlock(&dai->lock, key);
233243

234244
return stream_id;
235245
}
236246

237-
static int dai_get_fifo(struct dai *dai, int direction, int stream_id)
247+
__cold static int dai_get_fifo(struct dai *dai, int direction, int stream_id)
238248
{
239249
k_spinlock_key_t key = k_spin_lock(&dai->lock);
240250
const struct dai_properties *props = dai_get_properties(dai->dev, direction,
241251
stream_id);
242252
int fifo_address = props->fifo_address;
243253

254+
assert_can_be_cold();
255+
244256
k_spin_unlock(&dai->lock, key);
245257

246258
return fifo_address;
@@ -466,11 +478,13 @@ dai_dma_multi_endpoint_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t fr
466478
return dma_status;
467479
}
468480

469-
int dai_common_new(struct dai_data *dd, struct comp_dev *dev,
470-
const struct ipc_config_dai *dai_cfg)
481+
__cold int dai_common_new(struct dai_data *dd, struct comp_dev *dev,
482+
const struct ipc_config_dai *dai_cfg)
471483
{
472484
uint32_t dir;
473485

486+
assert_can_be_cold();
487+
474488
dd->dai = dai_get(dai_cfg->type, dai_cfg->dai_index, DAI_CREAT);
475489
if (!dd->dai) {
476490
comp_err(dev, "dai_get() failed to create DAI.");
@@ -541,15 +555,17 @@ int dai_common_new(struct dai_data *dd, struct comp_dev *dev,
541555
return 0;
542556
}
543557

544-
static struct comp_dev *dai_new(const struct comp_driver *drv,
545-
const struct comp_ipc_config *config,
546-
const void *spec)
558+
__cold static struct comp_dev *dai_new(const struct comp_driver *drv,
559+
const struct comp_ipc_config *config,
560+
const void *spec)
547561
{
548562
struct comp_dev *dev;
549563
const struct ipc_config_dai *dai_cfg = spec;
550564
struct dai_data *dd;
551565
int ret;
552566

567+
assert_can_be_cold();
568+
553569
comp_cl_dbg(&comp_dai, "dai_new()");
554570

555571
dev = comp_alloc(drv, sizeof(*dev));
@@ -581,8 +597,10 @@ static struct comp_dev *dai_new(const struct comp_driver *drv,
581597
return NULL;
582598
}
583599

584-
void dai_common_free(struct dai_data *dd)
600+
__cold void dai_common_free(struct dai_data *dd)
585601
{
602+
assert_can_be_cold();
603+
586604
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
587605
io_perf_monitor_release_slot(dd->io_perf_bytes_count);
588606
#endif
@@ -604,10 +622,12 @@ void dai_common_free(struct dai_data *dd)
604622
rfree(dd->dai_spec_config);
605623
}
606624

607-
static void dai_free(struct comp_dev *dev)
625+
__cold static void dai_free(struct comp_dev *dev)
608626
{
609627
struct dai_data *dd = comp_get_drvdata(dev);
610628

629+
assert_can_be_cold();
630+
611631
if (dd->group)
612632
notifier_unregister(dev, dd->group, NOTIFIER_ID_DAI_TRIGGER);
613633

@@ -617,12 +637,14 @@ static void dai_free(struct comp_dev *dev)
617637
rfree(dev);
618638
}
619639

620-
int dai_common_get_hw_params(struct dai_data *dd, struct comp_dev *dev,
621-
struct sof_ipc_stream_params *params, int dir)
640+
__cold int dai_common_get_hw_params(struct dai_data *dd, struct comp_dev *dev,
641+
struct sof_ipc_stream_params *params, int dir)
622642
{
623643
struct dai_config cfg;
624644
int ret;
625645

646+
assert_can_be_cold();
647+
626648
comp_dbg(dev, "dai_common_get_hw_params()");
627649

628650
ret = dai_config_get(dd->dai->dev, &cfg, dir);
@@ -644,21 +666,25 @@ int dai_common_get_hw_params(struct dai_data *dd, struct comp_dev *dev,
644666
return ret;
645667
}
646668

647-
static int dai_comp_get_hw_params(struct comp_dev *dev,
648-
struct sof_ipc_stream_params *params,
649-
int dir)
669+
__cold static int dai_comp_get_hw_params(struct comp_dev *dev,
670+
struct sof_ipc_stream_params *params,
671+
int dir)
650672
{
651673
struct dai_data *dd = comp_get_drvdata(dev);
652674

675+
assert_can_be_cold();
676+
653677
return dai_common_get_hw_params(dd, dev, params, dir);
654678
}
655679

656-
static int dai_verify_params(struct dai_data *dd, struct comp_dev *dev,
657-
struct sof_ipc_stream_params *params)
680+
__cold static int dai_verify_params(struct dai_data *dd, struct comp_dev *dev,
681+
struct sof_ipc_stream_params *params)
658682
{
659683
struct sof_ipc_stream_params hw_params;
660684
int ret;
661685

686+
assert_can_be_cold();
687+
662688
memset(&hw_params, 0, sizeof(hw_params));
663689

664690
ret = dai_common_get_hw_params(dd, dev, &hw_params, params->direction);
@@ -691,12 +717,14 @@ static int dai_verify_params(struct dai_data *dd, struct comp_dev *dev,
691717
return 0;
692718
}
693719

694-
static int dai_get_dma_slot(struct dai_data *dd, struct comp_dev *dev, uint32_t *slot)
720+
__cold static int dai_get_dma_slot(struct dai_data *dd, struct comp_dev *dev, uint32_t *slot)
695721
{
696722
struct dai_config cfg;
697723
int ret;
698724
int hs;
699725

726+
assert_can_be_cold();
727+
700728
ret = dai_config_get(dd->dai->dev, &cfg, dev->direction);
701729
if (ret < 0) {
702730
comp_err(dev, "failed to fetch DAI configuration");
@@ -723,15 +751,17 @@ static int dai_get_dma_slot(struct dai_data *dd, struct comp_dev *dev, uint32_t
723751
return 0;
724752
}
725753

726-
static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev, uint32_t period_bytes,
727-
uint32_t period_count)
754+
__cold static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev,
755+
uint32_t period_bytes, uint32_t period_count)
728756
{
729757
struct dma_sg_config *config = &dd->config;
730758
uint32_t local_fmt = audio_stream_get_frm_fmt(&dd->local_buffer->stream);
731759
uint32_t dma_fmt = audio_stream_get_frm_fmt(&dd->dma_buffer->stream);
732760
uint32_t fifo, max_block_count, buf_size;
733761
int err = 0;
734762

763+
assert_can_be_cold();
764+
735765
/* set up DMA configuration */
736766
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
737767
dd->process = pcm_get_conversion_function(local_fmt, dma_fmt);
@@ -822,14 +852,16 @@ static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev, uint32_t
822852
return err;
823853
}
824854

825-
static int dai_set_dma_config(struct dai_data *dd, struct comp_dev *dev)
855+
__cold static int dai_set_dma_config(struct dai_data *dd, struct comp_dev *dev)
826856
{
827857
struct dma_sg_config *config = &dd->config;
828858
struct dma_config *dma_cfg;
829859
struct dma_block_config *dma_block_cfg;
830860
struct dma_block_config *prev = NULL;
831861
int i;
832862

863+
assert_can_be_cold();
864+
833865
comp_dbg(dev, "dai_set_dma_config()");
834866

835867
dma_cfg = rballoc(SOF_MEM_FLAG_COHERENT, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
@@ -900,9 +932,9 @@ static int dai_set_dma_config(struct dai_data *dd, struct comp_dev *dev)
900932
return 0;
901933
}
902934

903-
static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
904-
const struct sof_ipc_stream_params *params,
905-
uint32_t *pb, uint32_t *pc)
935+
__cold static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
936+
const struct sof_ipc_stream_params *params,
937+
uint32_t *pb, uint32_t *pc)
906938
{
907939
struct sof_ipc_stream_params hw_params = *params;
908940
uint32_t frame_size;
@@ -914,6 +946,8 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
914946
uint32_t align;
915947
int err;
916948

949+
assert_can_be_cold();
950+
917951
comp_dbg(dev, "dai_set_dma_buffer()");
918952

919953
if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
@@ -1021,8 +1055,8 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
10211055
return 0;
10221056
}
10231057

1024-
int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
1025-
struct sof_ipc_stream_params *base_cfg_params)
1058+
__cold int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
1059+
struct sof_ipc_stream_params *base_cfg_params)
10261060
{
10271061
struct sof_ipc_stream_params params = *base_cfg_params;
10281062
struct sof_ipc_stream_params hw_params;
@@ -1031,6 +1065,8 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
10311065
uint32_t period_count = 0;
10321066
int err = 0;
10331067

1068+
assert_can_be_cold();
1069+
10341070
comp_dbg(dev, "dai_zephyr_params()");
10351071

10361072
/* configure dai_data first */
@@ -1094,19 +1130,23 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
10941130
return err;
10951131
}
10961132

1097-
static int dai_params(struct comp_dev *dev, struct sof_ipc_stream_params *params)
1133+
__cold static int dai_params(struct comp_dev *dev, struct sof_ipc_stream_params *params)
10981134
{
10991135
struct dai_data *dd = comp_get_drvdata(dev);
11001136

1137+
assert_can_be_cold();
1138+
11011139
comp_dbg(dev, "dai_params()");
11021140

11031141
return dai_common_params(dd, dev, params);
11041142
}
11051143

1106-
int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev)
1144+
__cold int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev)
11071145
{
11081146
int channel;
11091147

1148+
assert_can_be_cold();
1149+
11101150
/* cannot configure DAI while active */
11111151
if (dev->state == COMP_STATE_ACTIVE) {
11121152
comp_info(dev, "Component is in active state.");
@@ -1150,10 +1190,12 @@ int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev)
11501190
return 0;
11511191
}
11521192

1153-
int dai_common_prepare(struct dai_data *dd, struct comp_dev *dev)
1193+
__cold int dai_common_prepare(struct dai_data *dd, struct comp_dev *dev)
11541194
{
11551195
int ret;
11561196

1197+
assert_can_be_cold();
1198+
11571199
dd->total_data_processed = 0;
11581200

11591201
if (!dd->chan) {
@@ -1185,11 +1227,13 @@ int dai_common_prepare(struct dai_data *dd, struct comp_dev *dev)
11851227
return ret;
11861228
}
11871229

1188-
static int dai_prepare(struct comp_dev *dev)
1230+
__cold static int dai_prepare(struct comp_dev *dev)
11891231
{
11901232
struct dai_data *dd = comp_get_drvdata(dev);
11911233
int ret;
11921234

1235+
assert_can_be_cold();
1236+
11931237
comp_dbg(dev, "dai_prepare()");
11941238

11951239
ret = dai_common_config_prepare(dd, dev);
@@ -1900,11 +1944,13 @@ static uint64_t dai_get_processed_data(struct comp_dev *dev, uint32_t stream_no,
19001944
}
19011945

19021946
#ifdef CONFIG_IPC_MAJOR_4
1903-
int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, void *data)
1947+
__cold int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, void *data)
19041948
{
19051949
struct ipc4_module_bind_unbind *bu;
19061950
int buf_id;
19071951

1952+
assert_can_be_cold();
1953+
19081954
bu = (struct ipc4_module_bind_unbind *)data;
19091955
buf_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue);
19101956

0 commit comments

Comments
 (0)