-
Notifications
You must be signed in to change notification settings - Fork 350
user-space ll: grant access to DAIs and DMAs #10533
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
Changes from all commits
f9318e8
6dd04c4
4e1827b
a153d34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,6 +126,20 @@ static inline uint32_t user_get_partition_attr(uintptr_t ptr) | |
| return sys_cache_is_ptr_cached(UINT_TO_POINTER(ptr)) ? XTENSA_MMU_CACHED_WB : 0; | ||
| } | ||
|
|
||
| /** | ||
| * Grant DAI device access to a user-space thread. | ||
| * | ||
| * @param thread user-space thread for which DAI access is granted | ||
| */ | ||
| void user_grant_dai_access_all(struct k_thread *thread); | ||
|
||
|
|
||
| /** | ||
| * Grant DMA device access to a user-space thread. | ||
| * | ||
| * @param thread user-space thread for which DMA access is granted | ||
| */ | ||
| void user_grant_dma_access_all(struct k_thread *thread); | ||
|
||
|
|
||
| #else | ||
|
|
||
| static inline int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,16 +15,22 @@ | |
| #include <stdint.h> | ||
|
|
||
| #include <rtos/alloc.h> | ||
| #include <rtos/sof.h> | ||
| #include <rtos/userspace_helper.h> | ||
| #include <sof/audio/module_adapter/module/generic.h> | ||
| #include <sof/audio/module_adapter/library/userspace_proxy.h> | ||
| #include <sof/lib/mailbox.h> | ||
| #include <sof/lib/dai.h> | ||
| #include <sof/lib/dma.h> | ||
|
|
||
| #define MODULE_DRIVER_HEAP_CACHED CONFIG_SOF_ZEPHYR_HEAP_CACHED | ||
|
|
||
| /* Zephyr includes */ | ||
| #include <zephyr/kernel.h> | ||
| #include <zephyr/app_memory/app_memdomain.h> | ||
| #include <zephyr/logging/log.h> | ||
|
|
||
| LOG_MODULE_REGISTER(userspace_helper, CONFIG_SOF_LOG_LEVEL); | ||
|
|
||
| #if CONFIG_USERSPACE | ||
|
|
||
|
|
@@ -88,6 +94,8 @@ int user_memory_attach_common_partition(struct k_mem_domain *dom) | |
| return k_mem_domain_add_partition(dom, &common_partition); | ||
| } | ||
|
|
||
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
|
|
||
| int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id) | ||
|
Comment on lines
+97
to
99
|
||
| { | ||
| struct k_mem_partition mem_partition; | ||
|
|
@@ -128,6 +136,33 @@ int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id) | |
| return 0; | ||
| } | ||
|
|
||
| void user_grant_dai_access_all(struct k_thread *thread) | ||
| { | ||
| const struct device **devices; | ||
| size_t count; | ||
| size_t i; | ||
|
|
||
| devices = dai_get_device_list(&count); | ||
|
|
||
| for (i = 0; i < count; i++) | ||
| k_thread_access_grant(thread, devices[i]); | ||
|
|
||
| LOG_DBG("Granted DAI access to thread %p for %zu devices", thread, count); | ||
| } | ||
|
|
||
| void user_grant_dma_access_all(struct k_thread *thread) | ||
| { | ||
| const struct dma_info *info = dma_info_get(); | ||
| struct sof_dma *d; | ||
|
|
||
| for (d = info->dma_array; d < info->dma_array + info->num_dmas; d++) { | ||
| k_thread_access_grant(thread, d->z_dev); | ||
| LOG_DBG("Granted DMA device access: %s to thread %p", d->z_dev->name, thread); | ||
| } | ||
| } | ||
|
|
||
| #endif /* CONFIG_SOF_USERSPACE_LL */ | ||
|
|
||
| #else /* CONFIG_USERSPACE */ | ||
|
|
||
| void *user_stack_allocate(size_t stack_size, uint32_t options) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These calls are unconditional, but the implementations in
userspace_helper.care built only underCONFIG_USERSPACE && CONFIG_SOF_USERSPACE_LL(and currently the header declarations are not similarly guarded). This can lead to unresolved symbols in configurations where this file is compiled butCONFIG_SOF_USERSPACE_LL(or evenCONFIG_USERSPACE) is off. Guard these calls with the same Kconfig option(s), and/or providestatic inlineno-op stubs in the header for non-enabled configurations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a valid concern, but this code is already guarded by CONFIG_SOF_USERSPACE_LL and that depends on CONFIG_USERSPACE, so this is sufficient.