Skip to content

Commit ba3a903

Browse files
committed
schedule: dp: call directly instead of a notifier
scheduler_dp_ll_tick() is currently registered as a notifier callback, but it's always triggered deterministically, always with the same-core-only flag, which leads to it being called immediately. So the notifier only adds a layer of indirection and reduces clarity. Replace it with a direct function call. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent ce9f1aa commit ba3a903

6 files changed

Lines changed: 19 additions & 31 deletions

File tree

src/include/sof/schedule/dp_schedule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ int scheduler_dp_task_init(struct task **task,
7878
uint16_t core,
7979
size_t stack_size,
8080
uint32_t options);
81+
void scheduler_dp_ll_tick(void);
8182

8283
/**
8384
* \brief Extract information about scheduler's tasks

src/schedule/zephyr_dp_schedule.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <zephyr/sys/sem.h>
2323
#include <zephyr/sys/mutex.h>
2424
#include <sof/lib/memory.h>
25-
#include <sof/lib/notifier.h>
2625
#include <ipc4/base_fw.h>
2726

2827
#include "zephyr_dp_schedule.h"
@@ -223,19 +222,19 @@ static enum task_state scheduler_dp_ll_tick_dummy(void *data)
223222
* needed 1.2ms for processing - but the example would be too complicated)
224223
*/
225224

226-
void scheduler_dp_ll_tick(void *receiver_data, enum notify_id event_type, void *caller_data)
225+
void scheduler_dp_ll_tick(void)
227226
{
228-
(void)receiver_data;
229-
(void)event_type;
230-
(void)caller_data;
231227
unsigned int lock_key;
232228
struct scheduler_dp_data *dp_sch = scheduler_get_data(SOF_SCHEDULE_DP);
233229

230+
if (!dp_sch)
231+
return;
232+
234233
/* remember current timestamp as "NOW" */
235234
dp_sch->last_ll_tick_timestamp = k_cycle_get_32();
236235

237236
lock_key = scheduler_dp_lock(cpu_get_id());
238-
scheduler_dp_recalculate(dp_sch, event_type == NOTIFIER_ID_LL_POST_RUN);
237+
scheduler_dp_recalculate(dp_sch);
239238
scheduler_dp_unlock(lock_key);
240239
}
241240

@@ -347,10 +346,9 @@ static struct scheduler_ops schedule_dp_ops = {
347346
.schedule_task_free = scheduler_dp_task_free,
348347
};
349348

349+
/* Runs on each core */
350350
__cold int scheduler_dp_init(void)
351351
{
352-
int ret;
353-
354352
assert_can_be_cold();
355353

356354
struct scheduler_dp_data *dp_sch = rzalloc(SOF_MEM_FLAG_KERNEL,
@@ -364,18 +362,11 @@ __cold int scheduler_dp_init(void)
364362
scheduler_init(SOF_SCHEDULE_DP, &schedule_dp_ops, dp_sch);
365363

366364
/* init src of DP tick */
367-
ret = schedule_task_init_ll(&dp_sch->ll_tick_src,
368-
SOF_UUID(dp_sched_uuid),
369-
SOF_SCHEDULE_LL_TIMER,
370-
0, scheduler_dp_ll_tick_dummy, dp_sch,
371-
cpu_get_id(), 0);
372-
373-
if (ret)
374-
return ret;
375-
376-
notifier_register(NULL, NULL, NOTIFIER_ID_LL_POST_RUN, scheduler_dp_ll_tick, 0);
377-
378-
return 0;
365+
return schedule_task_init_ll(&dp_sch->ll_tick_src,
366+
SOF_UUID(dp_sched_uuid),
367+
SOF_SCHEDULE_LL_TIMER,
368+
0, scheduler_dp_ll_tick_dummy, dp_sch,
369+
cpu_get_id(), 0);
379370
}
380371

381372
void scheduler_get_task_info_dp(struct scheduler_props *scheduler_props, uint32_t *data_off_size)

src/schedule/zephyr_dp_schedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct task_dp_pdata {
5252
#endif
5353
};
5454

55-
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch, bool is_ll_post_run);
55+
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch);
5656
void dp_thread_fn(void *p1, void *p2, void *p3);
5757
unsigned int scheduler_dp_lock(uint16_t core);
5858
void scheduler_dp_unlock(unsigned int key);

src/schedule/zephyr_dp_schedule_application.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int scheduler_dp_thread_ipc(struct processing_module *pmod, unsigned int cmd,
197197
/* Go through all DP tasks and recalculate their readiness and deadlines
198198
* NOT REENTRANT, called with scheduler_dp_lock() held
199199
*/
200-
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch, bool is_ll_post_run)
200+
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch)
201201
{
202202
struct list_item *tlist;
203203
struct task *curr_task;
@@ -210,7 +210,7 @@ void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch, bool is_ll_post_
210210
bool trigger_task = false;
211211

212212
/* decrease number of LL ticks/cycles left till the module reaches its deadline */
213-
if (mod->dp_startup_delay && is_ll_post_run && pdata->ll_cycles_to_start) {
213+
if (mod->dp_startup_delay && pdata->ll_cycles_to_start) {
214214
pdata->ll_cycles_to_start--;
215215
if (!pdata->ll_cycles_to_start)
216216
/* delayed start complete, clear startup delay flag.

src/schedule/zephyr_dp_schedule_thread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern struct tr_ctx dp_tr;
3030
/* Go through all DP tasks and recalculate their readiness and deadlines
3131
* NOT REENTRANT, should be called with scheduler_dp_lock()
3232
*/
33-
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch, bool is_ll_post_run)
33+
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch)
3434
{
3535
struct list_item *tlist;
3636
struct task *curr_task;
@@ -43,7 +43,7 @@ void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch, bool is_ll_post_
4343
bool trigger_task = false;
4444

4545
/* decrease number of LL ticks/cycles left till the module reaches its deadline */
46-
if (mod->dp_startup_delay && is_ll_post_run && pdata->ll_cycles_to_start) {
46+
if (mod->dp_startup_delay && pdata->ll_cycles_to_start) {
4747
pdata->ll_cycles_to_start--;
4848
if (!pdata->ll_cycles_to_start)
4949
/* delayed start complete, clear startup delay flag.

src/schedule/zephyr_ll.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <sof/audio/component.h>
1111
#include <rtos/interrupt.h>
1212
#include <sof/lib/memory.h>
13-
#include <sof/lib/notifier.h>
13+
#include <sof/schedule/dp_schedule.h>
1414
#include <sof/schedule/ll_schedule_domain.h>
1515
#include <sof/schedule/schedule.h>
1616
#include <rtos/task.h>
@@ -344,11 +344,7 @@ static void zephyr_ll_run(void *data)
344344

345345
zephyr_ll_unlock(sch, &flags);
346346

347-
#ifndef CONFIG_SOF_USERSPACE_LL
348-
/* TODO: to be replaced with direct function calls */
349-
notifier_event(sch, NOTIFIER_ID_LL_POST_RUN,
350-
NOTIFIER_TARGET_CORE_LOCAL, NULL, 0);
351-
#endif
347+
scheduler_dp_ll_tick();
352348
}
353349

354350
static void schedule_ll_callback(void *data)

0 commit comments

Comments
 (0)