Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dp: delayed start should apply to the first DP cycle only #8842

Merged
merged 2 commits into from
Feb 12, 2024
Merged
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
8 changes: 6 additions & 2 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,10 @@ static int module_adapter_copy_dp_queues(struct comp_dev *dev)
source_get_data_available(data_src));

err = source_to_sink_copy(data_src, data_sink, true, to_copy);
if (err)
if (err) {
comp_err(dev, "LL to DP copy error status: %d", err);
return err;
}

dp_queue = dp_queue_get_next_item(dp_queue);
}
Expand Down Expand Up @@ -1080,8 +1082,10 @@ static int module_adapter_copy_dp_queues(struct comp_dev *dev)
source_get_data_available(data_src));

err = source_to_sink_copy(data_src, data_sink, true, to_copy);
if (err)
if (err) {
comp_err(dev, "DP to LL copy error status: %d", err);
return err;
}

dp_queue = dp_queue_get_next_item(dp_queue);
}
Expand Down
13 changes: 5 additions & 8 deletions src/schedule/zephyr_dp_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ struct scheduler_dp_data {
struct task_dp_pdata {
k_tid_t thread_id; /* zephyr thread ID */
uint32_t deadline_clock_ticks; /* dp module deadline in Zephyr ticks */
uint32_t deadline_ll_cycles; /* dp module deadline in LL cycles */
k_thread_stack_t __sparse_cache *p_stack; /* pointer to thread stack */
struct k_sem sem; /* semaphore for task scheduling */
struct processing_module *mod; /* the module to be scheduled */
uint32_t ll_cycles_to_deadline; /* current number of LL cycles till deadline */
uint32_t ll_cycles_to_start; /* current number of LL cycles till delayed start */
};

/* Single CPU-wide lock
Expand Down Expand Up @@ -233,9 +232,9 @@ void scheduler_dp_ll_tick(void *receiver_data, enum notify_id event_type, void *
struct processing_module *mod = pdata->mod;

/* decrease number of LL ticks/cycles left till the module reaches its deadline */
if (pdata->ll_cycles_to_deadline) {
pdata->ll_cycles_to_deadline--;
if (!pdata->ll_cycles_to_deadline)
if (pdata->ll_cycles_to_start) {
pdata->ll_cycles_to_start--;
if (!pdata->ll_cycles_to_start)
/* deadline reached, clear startup delay flag.
* see dp_startup_delay comment for details
*/
Expand All @@ -253,7 +252,6 @@ void scheduler_dp_ll_tick(void *receiver_data, enum notify_id event_type, void *
/* set a deadline for given num of ticks, starting now */
k_thread_deadline_set(pdata->thread_id,
pdata->deadline_clock_ticks);
pdata->ll_cycles_to_deadline = pdata->deadline_ll_cycles;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can see, that this re-arming is useless, but it seems it should be harmless, since the dp_startup_delay flag is only set to true once during task initialisation? What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

flag may never be set to false if re-arming occurs too early. That hurts.


/* trigger the task */
curr_task->state = SOF_TASK_STATE_RUNNING;
Expand Down Expand Up @@ -391,8 +389,7 @@ static int scheduler_dp_task_shedule(void *data, struct task *task, uint64_t sta
deadline_clock_ticks /= 1000000;

pdata->deadline_clock_ticks = deadline_clock_ticks;
pdata->deadline_ll_cycles = period / LL_TIMER_PERIOD_US;
pdata->ll_cycles_to_deadline = 0;
pdata->ll_cycles_to_start = period / LL_TIMER_PERIOD_US;
pdata->mod->dp_startup_delay = true;
scheduler_dp_unlock(lock_key);

Expand Down
Loading