-
Notifications
You must be signed in to change notification settings - Fork 350
zephyr: userspace_helper: add test_mailbox.c (plus a test) #10477
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 1 commit
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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| #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> | ||
|
|
||
| #define MODULE_DRIVER_HEAP_CACHED CONFIG_SOF_ZEPHYR_HEAP_CACHED | ||
|
|
||
|
|
@@ -82,6 +83,46 @@ int user_memory_init_shared(k_tid_t thread_id, struct processing_module *mod) | |
| return k_mem_domain_add_thread(comp_dom, thread_id); | ||
| } | ||
|
|
||
| int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id) | ||
| { | ||
| struct k_mem_partition mem_partition; | ||
| int ret; | ||
|
|
||
| /* | ||
| * Start with mailbox_swregs. This is aligned with mailbox.h | ||
| * implementation with uncached addressed used for register I/O. | ||
| */ | ||
| mem_partition.start = | ||
| (uintptr_t)sys_cache_uncached_ptr_get((void __sparse_cache *)MAILBOX_SW_REG_BASE); | ||
|
|
||
| BUILD_ASSERT(MAILBOX_SW_REG_SIZE == CONFIG_MMU_PAGE_SIZE); | ||
| mem_partition.size = CONFIG_MMU_PAGE_SIZE; | ||
| mem_partition.attr = K_MEM_PARTITION_P_RW_U_RW; | ||
|
|
||
| ret = k_mem_domain_add_partition(domain, &mem_partition); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| #ifndef CONFIG_IPC_MAJOR_4 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Userspace with IPC3? really?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lyakh Probably no, but there is no technical relation with userspace and IPC protocol version. I did this test with a brute force check of how mailbox.h is used in SOF application code and tried to cover all usages in this test PR. If I assume some functions are only used with IPC4 (see #10480 ), and then proceed to to only test with another assumption that user-space is only used in IPC4, I'm not sure if future SOF maintainers will appreciate this. OTOH, I can just drop this as well -- this won't prevent IPC3 usage either.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, long life support for IPC3 :)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kv2019i My concern is purely practical - dead code. Has anyone ever tested userspace with IPC3? I suspect (and hope) that not. And I estimate the probability of this ever being used as very low, but you might know something that I don't! So, if I'm right and there's no somewhat realistic chance of this being used - please let's remove this. |
||
| /* | ||
| * Next mailbox_stream (not available in IPC4). Stream access is cached, | ||
| * so different mapping this time. | ||
| */ | ||
| mem_partition.start = | ||
| (uintptr_t)sys_cache_cached_ptr_get((void *)SRAM_STREAM_BASE); | ||
| BUILD_ASSERT(MAILBOX_STREAM_SIZE == CONFIG_MMU_PAGE_SIZE); | ||
| /* size and attr the same as for mailbox_swregs */ | ||
|
|
||
| ret = k_mem_domain_add_partition(domain, &mem_partition); | ||
| if (ret < 0) | ||
| return ret; | ||
| #endif | ||
|
|
||
| k_mem_domain_add_thread(domain, thread_id); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| #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.
@kv2019i oh, wait... don't we need a method to remove the partition too? This is for the LL scheduling thread, right? Would it be restarted during the life time of the firmware? If so, then we need to remove the partition too.