Skip to content

Commit 741722b

Browse files
committed
debug
1 parent d2b6af3 commit 741722b

4 files changed

Lines changed: 81 additions & 47 deletions

File tree

src/audio/module_adapter/library/userspace_proxy.c

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,27 @@ void userspace_proxy_handle_request(struct processing_module *mod)
252252
k_msgq_put(mod->user_ctx->out_msgq, &params, K_FOREVER);
253253

254254
}
255-
255+
#define WORK_DEBUG() do { worker_data.line = __LINE__; } while (0)
256256
static void call_agent_user(struct k_work_user *work_item)
257257
{
258258
struct user_worker_item *wd = CONTAINER_OF(work_item, struct user_worker_item, work_item);
259-
struct module_params *params = (struct module_params *)wd->ipc_params;
260-
k_msgq_get(wd->tmp_in_msgq, params, K_FOREVER);
261-
262-
userspace_proxy_handle_request_params(params->mod, params);
263-
k_msgq_put(wd->tmp_out_msgq, params, K_FOREVER);
259+
//struct module_params *params = (struct module_params *)wd->ipc_params;
260+
struct module_params params;
261+
WORK_DEBUG();
262+
k_msgq_get(wd->tmp_in_msgq, &params, K_FOREVER);
263+
WORK_DEBUG();
264+
while (params.cmd != MODULE_CMD_AGENT_START);
265+
WORK_DEBUG();
266+
params.status = params.ext.agent.start_fn(params.ext.agent.entry_point,
267+
params.ext.agent.module_id,
268+
params.ext.agent.instance_id,
269+
params.ext.agent.core_id,
270+
params.ext.agent.log_handle,
271+
&params.ext.agent.mod_cfg,
272+
&params.ext.agent.iface);
273+
WORK_DEBUG();
274+
k_msgq_put(wd->tmp_out_msgq, &params, K_FOREVER);
275+
WORK_DEBUG();
264276
}
265277

266278
static int userspace_proxy_msgq_alloc(struct userspace_context *context)
@@ -356,19 +368,19 @@ static void user_worker_free(struct userspace_context *user)
356368
}
357369
}
358370

359-
static int user_worker_call(struct userspace_context *user_ctx, struct processing_module *mod,
360-
uint32_t cmd, struct module_params *params)
371+
static int user_worker_call_agent(struct userspace_context *user_ctx, struct module_params *params)
361372
{
362373
int ret;
363374

364375
params->context = user_ctx;
365-
params->mod = mod;
366-
params->cmd = cmd;
376+
params->cmd = MODULE_CMD_AGENT_START;
377+
378+
user_add_memory(user_ctx->comp_dom, POINTER_TO_UINT(worker.p_worker_stack), CONFIG_SOF_STACK_SIZE, K_MEM_PARTITION_P_RW_U_RW);
367379

368380
/* Switch worker thread to module memory domain */
369381
ret = k_mem_domain_add_thread(user_ctx->comp_dom, worker.ipc_worker_tid);
370382
if (ret < 0) {
371-
comp_err(mod->dev, "failed to switch memory domain: error: %d", ret);
383+
tr_err(&modules_user_tr, "failed to switch memory domain: error: %d", ret);
372384
return ret;
373385
}
374386

@@ -385,49 +397,21 @@ static int user_worker_call(struct userspace_context *user_ctx, struct processin
385397
if (ret < 0)
386398
return ret;
387399

388-
389-
390-
391-
392-
ret = k_msgq_put(user_ctx->in_msgq, params, K_FOREVER);
400+
ret = k_msgq_put(user_ctx->in_msgq, params, K_USEC(1000*1000));
393401
if (ret < 0) {
394-
comp_err(mod->dev, "k_msgq_put(): error: %d", ret);
402+
tr_err(&modules_user_tr, "k_msgq_put(): error: %d", ret);
395403
return ret;
396404
}
397405

398406

399-
ret = k_msgq_get(user_ctx->out_msgq, params, K_FOREVER);
407+
ret = k_msgq_get(user_ctx->out_msgq, params, K_USEC(1000*1000));
400408
if (ret < 0)
401-
comp_err(mod->dev, "k_msgq_get(): error: %d", ret);
409+
tr_err(&modules_user_tr, "k_msgq_get(): error: %d", ret);
402410

403411
return ret;
404412
}
405413
int debug_line_adapter;
406414
int debug_line_adapter2;
407-
static int userspace_proxy_invoke(struct userspace_context *user, struct processing_module *mod,
408-
uint32_t cmd, struct module_params *params)
409-
{
410-
int ret;
411-
412-
params->context = user;
413-
params->mod = mod;
414-
params->cmd = cmd;
415-
comp_err(mod->dev, "cmd %d", cmd);
416-
417-
ret = k_msgq_put(user->in_msgq, params, K_USEC(1000*1000));// K_FOREVER);
418-
if (ret < 0) {
419-
comp_err(mod->dev, "k_msgq_put(): error: %d", ret);
420-
return ret;
421-
}
422-
423-
ret = k_msgq_get(user->out_msgq, params, K_USEC(2000*1000));
424-
if (ret < 0)
425-
comp_err(mod->dev, "k_msgq_get(): error: %d, line: %d, line2: %d, adapter: %d %d", ret,
426-
worker_data.line, worker_data.line2, debug_line_adapter, debug_line_adapter2);
427-
428-
return ret;
429-
}
430-
431415
static uintptr_t call_agent(struct userspace_context *user_ctx, system_agent_start_fn start_fn,
432416
uintptr_t entry_point, uint32_t module_id, uint32_t instance_id,
433417
uint32_t core_id, uint32_t log_handle, byte_array_t *mod_cfg,
@@ -453,7 +437,7 @@ static uintptr_t call_agent(struct userspace_context *user_ctx, system_agent_sta
453437
if (ret)
454438
goto error_worker;
455439

456-
ret = user_worker_call(user_ctx, NULL, MODULE_CMD_AGENT_START, &params);
440+
ret = user_worker_call_agent(user_ctx, &params);
457441
if (ret)
458442
goto error_worker;
459443

@@ -537,6 +521,30 @@ static int userspace_proxy_add_sections(struct userspace_context *user, uint32_t
537521
K_MEM_PARTITION_P_RW_U_RW);
538522
}
539523

524+
static int userspace_proxy_invoke(struct userspace_context *user, struct processing_module *mod,
525+
uint32_t cmd, struct module_params *params)
526+
{
527+
int ret;
528+
529+
params->context = user;
530+
params->mod = mod;
531+
params->cmd = cmd;
532+
comp_err(mod->dev, "cmd %d", cmd);
533+
534+
ret = k_msgq_put(user->in_msgq, params, K_USEC(1000*1000));// K_FOREVER);
535+
if (ret < 0) {
536+
comp_err(mod->dev, "k_msgq_put(): error: %d", ret);
537+
return ret;
538+
}
539+
540+
ret = k_msgq_get(user->out_msgq, params, K_USEC(2000*1000));
541+
if (ret < 0)
542+
comp_err(mod->dev, "k_msgq_get(): error: %d, line: %d, line2: %d, adapter: %d %d", ret,
543+
worker_data.line, worker_data.line2, debug_line_adapter, debug_line_adapter2);
544+
545+
return ret;
546+
}
547+
540548
//#include <zephyr/arch/xtensa/include/xtensa_mmu_priv.h>
541549
//#include <arch/xtensa/include/xtensa_mmu_priv.h>
542550
//#include <xtensa/include/xtensa_mmu_priv.h>

src/audio/module_adapter/module/generic.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <rtos/symbol.h>
1515

1616
#include <sof/audio/module_adapter/module/generic.h>
17+
Z_GENERIC_SECTION(.app_regions.common_partition)
18+
#define DEBUG() do { mod->debug[0] = 20000 + __LINE__; } while (0)
1719

1820
LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL);
1921

@@ -263,14 +265,24 @@ int module_process_legacy(struct processing_module *mod,
263265
return 0;
264266
}
265267

268+
//__attribute__((optimize("-O0")))
266269
int module_process_sink_src(struct processing_module *mod,
267270
struct sof_source **sources, int num_of_sources,
268271
struct sof_sink **sinks, int num_of_sinks)
269272

270273
{
274+
DEBUG();
275+
271276
struct comp_dev *dev = mod->dev;
272-
const struct module_interface *const ops = dev->drv->adapter_ops;
277+
DEBUG();
278+
const struct comp_driver *const drv = dev->drv;
279+
DEBUG();
280+
281+
const struct module_interface *const ops = drv->adapter_ops;
282+
DEBUG();
283+
273284
int ret;
285+
DEBUG();
274286

275287
comp_dbg(dev, "module_process sink src() start");
276288

@@ -285,8 +297,11 @@ int module_process_sink_src(struct processing_module *mod,
285297
/* set state to processing */
286298
md->state = MODULE_PROCESSING;
287299
#endif
300+
DEBUG();
288301
assert(ops->process);
302+
DEBUG();
289303
ret = ops->process(mod, sources, num_of_sources, sinks, num_of_sinks);
304+
DEBUG();
290305

291306
if (ret && ret != -ENOSPC && ret != -ENODATA) {
292307
comp_err(dev, "module_process() error %d: for comp %d",

src/audio/pipeline/pipeline-schedule.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,25 @@ int pipeline_comp_ll_task_init(struct pipeline *p)
368368
return 0;
369369
}
370370

371+
#define DEBUG() do { mod->debug[0] = 10000 + __LINE__; } while (0)
372+
//Z_GENERIC_SECTION(.app_regions.common_partition)
373+
371374
#if CONFIG_ZEPHYR_DP_SCHEDULER
375+
__attribute__((optimize("-O0")))
372376
static enum task_state dp_task_run(void *data)
373377
{
374378
struct processing_module *mod = data;
375-
379+
DEBUG();
376380
int ret = module_process_sink_src(mod, mod->sources, mod->num_of_sources,
377381
mod->sinks, mod->num_of_sinks);
378-
if (ret)
382+
DEBUG();
383+
384+
if (ret) {
385+
DEBUG();
379386
pipeline_comp_copy_error_notify(mod->dev, ret);
387+
DEBUG();
388+
}
389+
DEBUG();
380390

381391
return SOF_TASK_STATE_RESCHEDULE;
382392
}

src/schedule/zephyr_dp_schedule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ static void dp_thread_fn(void *p1, void *p2, void *p3)
410410
/* the thread is started immediately after creation, it will stop on poll.
411411
* Signal will be raised once the task is ready to process
412412
*/
413+
DEBUG();
413414
ret = k_poll(events, events_count, K_FOREVER);
414415
DEBUG();
415416
mod->debug[1] = ret;

0 commit comments

Comments
 (0)