@@ -49,6 +49,7 @@ DECLARE_TR_CTX(userspace_proxy_tr, SOF_UUID(userspace_proxy_uuid), LOG_LEVEL_INF
4949
5050static const struct module_interface userspace_proxy_interface ;
5151
52+ #if !IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
5253/* IPC requests targeting userspace modules are handled through a user work queue.
5354 * Each userspace module provides its own work item that carries the IPC request parameters.
5455 * The worker thread is switched into the module's memory domain and receives the work item.
@@ -140,6 +141,7 @@ static void user_work_item_free(struct userspace_context *user_ctx, struct k_hea
140141 sof_heap_free (user_heap , user_ctx -> work_item );
141142 user_worker_put ();
142143}
144+ #endif
143145
144146static inline struct module_params * user_work_get_params (struct userspace_context * user_ctx )
145147{
@@ -174,6 +176,7 @@ static int userspace_proxy_invoke(struct userspace_context *user_ctx, uint32_t c
174176 }
175177 }
176178
179+ #if !IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
177180 /* Switch worker thread to module memory domain */
178181 ret = k_mem_domain_add_thread (user_ctx -> comp_dom , worker .thread_id );
179182 if (ret < 0 ) {
@@ -193,6 +196,7 @@ static int userspace_proxy_invoke(struct userspace_context *user_ctx, uint32_t c
193196 tr_err (& userspace_proxy_tr , "Submit to queue error: %d" , ret );
194197 goto done ;
195198 }
199+ #endif
196200
197201 /* Timeout value is aligned with the ipc_wait_for_compound_msg function */
198202 if (!k_event_wait_safe (& worker .event , DP_TASK_EVENT_IPC_DONE , false,
@@ -316,15 +320,25 @@ static int userspace_proxy_start_agent(struct userspace_context *user_ctx,
316320 int ret ;
317321
318322 params -> ext .agent .start_fn = start_fn ;
319- params -> ext .agent .params = * agent_params ;
320- params -> ext .agent .mod_cfg = * mod_cfg ;
321323
322- ret = userspace_proxy_invoke (user_ctx , USER_PROXY_MOD_CMD_AGENT_START , true);
323- if (ret )
324- return ret ;
324+ /* Start the system agent, if provided. */
325+ if (start_fn ) {
326+ params -> ext .agent .params = * agent_params ;
327+ params -> ext .agent .mod_cfg = * mod_cfg ;
325328
326- * agent_interface = params -> ext .agent .out_interface ;
327- return params -> status ;
329+ /* In case of processing modules ipc in the DP thread, the agent will be started in the
330+ * init function. At this point the DP thread does not exist yet.
331+ */
332+ #if !IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
333+ ret = userspace_proxy_invoke (user_ctx , USER_PROXY_MOD_CMD_AGENT_START , true);
334+ if (ret )
335+ return ret ;
336+
337+ * agent_interface = params -> ext .agent .out_interface ;
338+ return params -> status ;
339+ }
340+ #endif
341+ return 0 ;
328342}
329343
330344int userspace_proxy_create (struct userspace_context * * user_ctx , const struct comp_driver * drv ,
@@ -362,14 +376,10 @@ int userspace_proxy_create(struct userspace_context **user_ctx, const struct com
362376 if (ret )
363377 goto error_dom ;
364378
365- /* Start the system agent, if provided. */
366-
367- if (start_fn ) {
368- ret = userspace_proxy_start_agent (context , start_fn , agent_params , agent_interface );
369- if (ret ) {
370- tr_err (& userspace_proxy_tr , "System agent failed with error %d." , ret );
371- goto error_work_item ;
372- }
379+ ret = userspace_proxy_start_agent (context , start_fn , agent_params , agent_interface );
380+ if (ret ) {
381+ tr_err (& userspace_proxy_tr , "System agent failed with error %d." , ret );
382+ goto error_work_item ;
373383 }
374384
375385 * user_ctx = context ;
@@ -420,6 +430,20 @@ static int userspace_proxy_init(struct processing_module *mod)
420430
421431 comp_dbg (mod -> dev , "start" );
422432
433+ #if IS_ENABLED (CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD )
434+ /* Start the system agent, if provided. Params is already filled by
435+ * the userspace_proxy_start_agent function.
436+ */
437+ if (params -> ext .agent .start_fn ) {
438+ ret = userspace_proxy_invoke (mod -> user_ctx , USER_PROXY_MOD_CMD_AGENT_START , true);
439+ if (ret )
440+ return ret ;
441+
442+ * agent_interface = params -> ext .agent .out_interface ;
443+ mod -> user_ctx -> interface = * ops ;
444+ }
445+ #endif
446+
423447 params -> mod = mod ;
424448 ret = userspace_proxy_invoke (mod -> user_ctx , USER_PROXY_MOD_CMD_INIT , true);
425449 if (ret )
0 commit comments