Skip to content
Merged
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
30 changes: 29 additions & 1 deletion src/schedule/zephyr_dma_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@ LOG_MODULE_DECLARE(ll_schedule, CONFIG_SOF_LOG_LEVEL);
#define SEM_LIMIT 1
#define ZEPHYR_PDOMAIN_STACK_SIZE 8192

#if CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY
#define ZEPHYR_DMA_DOMAIN_THREAD_PRIO (CONFIG_LOG_PROCESS_THREAD_PRIORITY - 1)
#else
#define ZEPHYR_DMA_DOMAIN_THREAD_PRIO (K_LOWEST_APPLICATION_THREAD_PRIO - 1)
#endif /* CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY */

/* sanity check regarding the DMA domain's priority.
*
* VERY IMPORTANT: the Zephyr DMA domain's thread priority needs to be
* higher than the logging thread's. If this criteria is not met then
* issues such as buzzing noise when PAUSING/RESUMING a stream due to
* the SAI being underrun may appear. We also want to keep Zephyr DMA
* domain's thread priority in the preemptible range so as to not
* disturb the other Zephyr threads used by SOF (preferably the Zephyr
* DMA domain's thread priority should be lower than the lowest priority
* of the threads used by SOF which is 1 (EDF_SCHEDULER)).
*
* The Zephyr DMA domain's thread priority is unimportant as long as it
* meets the above criteria but we'll make it one less than the logging
* thread's for cases where the user might want to change the logging
* thread's priority.
*
* TODO: this message and the BUILD_ASSERT message need to be updated if
* the lowest priority used by the SOF threads is changed.
*/
BUILD_ASSERT(ZEPHYR_DMA_DOMAIN_THREAD_PRIO >= 0,
"Invalid DMA domain thread priority. Please make sure that logging threads priority is >= 1 or, preferably, >= 3");

K_KERNEL_STACK_ARRAY_DEFINE(zephyr_dma_domain_stack,
CONFIG_CORE_COUNT,
ZEPHYR_PDOMAIN_STACK_SIZE);
Expand Down Expand Up @@ -305,7 +333,7 @@ static int zephyr_dma_domain_register(struct ll_schedule_domain *domain,
dt,
NULL,
NULL,
CONFIG_NUM_PREEMPT_PRIORITIES - 1,
ZEPHYR_DMA_DOMAIN_THREAD_PRIO,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why are you actually using such a low priority (a high priority number) for the DMA domain? With the Zephyr domain we use the highest available priority -CONFIG_NUM_COOP_PRIORITIES

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's mostly due to the fact that its priority being in the preemptive range hasn't caused us any issues that I'm aware of. I think we can leave this in the preemptive range and switch over to cooperative range if there's ever a reason to.

0,
K_FOREVER);

Expand Down