You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stopping/Pausing a CHAIN_DMA stream takes 100ms #8445
this is what is going on: chain_task_pause() -> schedule_task_free() ->zephyr_ll_task_free() -> k_sem_take(&pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));
On zephyr_ll_run() pdata->freeing is true for the ChainDMA:
if (pdata->freeing) {
/* * zephyr_ll_task_free() is trying to free this task. * complete it and signal the semaphore to let the * function proceed */zephyr_ll_task_done(sch, task);
k_sem_give(&pdata->sem);
} elseif (state==SOF_TASK_STATE_COMPLETED) {
and we have this in zephyr_ll_task_done():
/* * If this is the last task, domain_unregister() won't return. It is * important to decrement the task counter last before aborting the * thread. */domain_unregister(sch->ll_domain, task, --sch->n_tasks);
With a single HDMI playback we have one task and that is what we are stopping, domain_unregister() will not return and we are not going to call k_sem_give(&pdata->sem) which means that zephyr_ll_task_free() will wait the maximum of 100ms before continuing.
If we have two ChainDMA playbacks and we only pause/stop one of them then the domain_unregister() will return and the k_sem_give() is called -> we don't have the 100ms time to pause/stop ChainDMA stream:
There was one failure in daily tests with commit 1bd9e0d, right before the #8451 fix was merged:
34373?model=TGLU_UP_HDA-ipc4&testcase=multiple-pause-resume-50
This failure was extremely rare. Rather than letting GitHub's auto-close this issue (anti--feature https://github.com/orgs/community/discussions/23476), let's make sure it does not happen for about a week and only then close it.
Activity
ujfalusi commentedon Nov 6, 2023
@plbossart, this is a firmware feature. The roundtrip of the message alone is ~100ms:
and this is not random, but constant.
CC: @jsarha,@makarukp
ujfalusi commentedon Nov 6, 2023
the firmware log:
ujfalusi commentedon Nov 6, 2023
this is the call that takes ~100ms:
https://github.com/thesofproject/sof/blob/main/src/audio/chain_dma.c#L383
ujfalusi commentedon Nov 6, 2023
@plbossart, and to be precise, pausing ChainDMA also takes 100ms, the
0xe050000is a pause commandujfalusi commentedon Nov 6, 2023
this is what is going on:
chain_task_pause()-> schedule_task_free() ->zephyr_ll_task_free() ->k_sem_take(&pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));On
zephyr_ll_run()pdata->freeing is true for the ChainDMA:and we have this in
zephyr_ll_task_done():With a single HDMI playback we have one task and that is what we are stopping,
domain_unregister()will not return and we are not going to callk_sem_give(&pdata->sem)which means thatzephyr_ll_task_free()will wait the maximum of 100ms before continuing.If we have two ChainDMA playbacks and we only pause/stop one of them then the
domain_unregister()will return and thek_sem_give()is called -> we don't have the 100ms time to pause/stop ChainDMA stream:I'm not familiar with the scheduling, @lyakh, @kv2019i FYI
ujfalusi commentedon Nov 6, 2023
Moving to firmware
[-]Stopping a CHAIN_DMA stream takes 100ms[/-][+]Stopping/Pausing a CHAIN_DMA stream takes 100ms[/+]plbossart commentedon Nov 6, 2023
nice work @ujfalusi. The response time should not depend on the number of active CHAIN_DMA streams, that's a code flow problem clearly.
chain-dma: cancel a task before freeing it
schedule: cancel a task before freeing it
schedule: cancel a task before freeing it
marc-hb commentedon Nov 10, 2023
There was one failure in daily tests with commit 1bd9e0d, right before the #8451 fix was merged:
34373?model=TGLU_UP_HDA-ipc4&testcase=multiple-pause-resume-50
This failure was extremely rare. Rather than letting GitHub's auto-close this issue (anti--feature https://github.com/orgs/community/discussions/23476), let's make sure it does not happen for about a week and only then close it.
plbossart commentedon Jul 23, 2024
@marc-hb @kv2019i I don't think this issue should remain open, no one has reported any updated in 8+ months.