@@ -51,6 +51,26 @@ static const struct module_interface userspace_proxy_interface;
5151
5252#if IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
5353#include <sof/audio/module_adapter/iadk/system_agent.h>
54+ #include <sof/schedule/dp_schedule.h>
55+
56+ static inline int user_worker_get (void )
57+ {
58+ return 0 ;
59+ }
60+ static inline void user_worker_put (void ) { }
61+
62+ struct k_work_user * userspace_proxy_register_ipc_handler (struct processing_module * mod ,
63+ struct k_event * event )
64+ {
65+ struct userspace_context * const user_ctx = mod -> user_ctx ;
66+ if (user_ctx ) {
67+ user_ctx -> dp_event = event ;
68+ assert (user_ctx -> work_item );
69+ return & user_ctx -> work_item -> work_item ;
70+ }
71+
72+ return NULL ;
73+ }
5474#else
5575/* IPC requests targeting userspace modules are handled through a user work queue.
5676 * Each userspace module provides its own work item that carries the IPC request parameters.
@@ -109,6 +129,7 @@ static void user_worker_put(void)
109129 user_stack_free (worker .stack_ptr );
110130 }
111131}
132+ #endif
112133
113134static int user_work_item_init (struct userspace_context * user_ctx , struct k_heap * user_heap )
114135{
@@ -131,7 +152,9 @@ static int user_work_item_init(struct userspace_context *user_ctx, struct k_heap
131152
132153 k_work_user_init (& work_item -> work_item , userspace_proxy_worker_handler );
133154
155+ #if !IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
134156 work_item -> event = & worker .event ;
157+ #endif
135158 work_item -> params .context = user_ctx ;
136159 user_ctx -> work_item = work_item ;
137160
@@ -143,7 +166,6 @@ static void user_work_item_free(struct userspace_context *user_ctx, struct k_hea
143166 sof_heap_free (user_heap , user_ctx -> work_item );
144167 user_worker_put ();
145168}
146- #endif
147169
148170static inline struct module_params * user_work_get_params (struct userspace_context * user_ctx )
149171{
@@ -159,6 +181,11 @@ BUILD_ASSERT(IS_ALIGNED(MAILBOX_HOSTBOX_SIZE, CONFIG_MMU_PAGE_SIZE),
159181static int userspace_proxy_invoke (struct userspace_context * user_ctx , uint32_t cmd ,
160182 bool ipc_payload_access )
161183{
184+ #if IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
185+ struct k_event * const event = user_ctx -> dp_event ;
186+ #else
187+ struct k_event * const event = & worker .event ;
188+ #endif
162189 struct module_params * params = user_work_get_params (user_ctx );
163190 const uintptr_t ipc_req_buf = (uintptr_t )MAILBOX_HOSTBOX_BASE ;
164191 struct k_mem_partition ipc_part = {
@@ -198,10 +225,13 @@ static int userspace_proxy_invoke(struct userspace_context *user_ctx, uint32_t c
198225 tr_err (& userspace_proxy_tr , "Submit to queue error: %d" , ret );
199226 goto done ;
200227 }
228+ #else
229+ assert (event );
230+ k_event_post (event , DP_TASK_EVENT_IPC );
201231#endif
202232
203233 /* Timeout value is aligned with the ipc_wait_for_compound_msg function */
204- if (!k_event_wait_safe (& worker . event , DP_TASK_EVENT_IPC_DONE , false,
234+ if (!k_event_wait_safe (event , DP_TASK_EVENT_IPC_DONE , false,
205235 Z_TIMEOUT_US (250 * 20 ))) {
206236 tr_err (& userspace_proxy_tr , "IPC processing timedout." );
207237 ret = - ETIMEDOUT ;
@@ -319,7 +349,6 @@ static int userspace_proxy_start_agent(struct userspace_context *user_ctx,
319349{
320350 const byte_array_t * const mod_cfg = (byte_array_t * )agent_params -> mod_cfg ;
321351 struct module_params * params = user_work_get_params (user_ctx );
322- int ret ;
323352
324353 params -> ext .agent .start_fn = start_fn ;
325354
@@ -332,7 +361,7 @@ static int userspace_proxy_start_agent(struct userspace_context *user_ctx,
332361 * init function. At this point the DP thread does not exist yet.
333362 */
334363#if !IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
335- ret = userspace_proxy_invoke (user_ctx , USER_PROXY_MOD_CMD_AGENT_START , true);
364+ int ret = userspace_proxy_invoke (user_ctx , USER_PROXY_MOD_CMD_AGENT_START , true);
336365 if (ret )
337366 return ret ;
338367
0 commit comments