Skip to content

Commit 342fd7b

Browse files
committed
debug
1 parent 5096112 commit 342fd7b

3 files changed

Lines changed: 44 additions & 34 deletions

File tree

src/audio/module_adapter/library/userspace_proxy.c

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -197,86 +197,86 @@ static int userspace_proxy_invoke(struct userspace_context *user_ctx, uint32_t c
197197
#endif
198198
struct module_params *params = user_work_get_params(user_ctx);
199199
struct processing_module *mod = params->mod;
200-
MOD_DBG(mod);
200+
DEBUG(mod);
201201
const uintptr_t ipc_req_buf = (uintptr_t)MAILBOX_HOSTBOX_BASE;
202-
MOD_DBG(mod);
202+
DEBUG(mod);
203203
struct k_mem_partition ipc_part = {
204204
.start = ipc_req_buf,
205205
.size = MAILBOX_HOSTBOX_SIZE,
206206
.attr = user_get_partition_attr(ipc_req_buf) | K_MEM_PARTITION_P_RO_U_RO,
207207
};
208-
MOD_DBG(mod);
208+
DEBUG(mod);
209209
int ret = 0, ret2;
210210

211211
params->cmd = cmd;
212-
MOD_DBG(mod);
212+
DEBUG(mod);
213213

214214
if (ipc_payload_access) {
215215
ret = k_mem_domain_add_partition(user_ctx->comp_dom, &ipc_part);
216-
MOD_DBG(mod);
216+
DEBUG(mod);
217217
if (ret < 0) {
218218
tr_err(&userspace_proxy_tr, "Add mailbox to domain error: %d", ret);
219-
MOD_DBG(mod);
219+
DEBUG(mod);
220220
return ret;
221221
}
222222
}
223-
MOD_DBG(mod);
223+
DEBUG(mod);
224224

225225
#if !IS_ENABLED(CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD)
226226
/* Switch worker thread to module memory domain */
227227
ret = k_mem_domain_add_thread(user_ctx->comp_dom, worker.thread_id);
228-
MOD_DBG(mod);
228+
DEBUG(mod);
229229
if (ret < 0) {
230230
tr_err(&userspace_proxy_tr, "Failed to switch memory domain, error: %d", ret);
231-
MOD_DBG(mod);
231+
DEBUG(mod);
232232
goto done;
233233
}
234234

235235
/* Pin worker thread to the same core as the module */
236236
ret = k_thread_cpu_pin(worker.thread_id, cpu_get_id());
237-
MOD_DBG(mod);
237+
DEBUG(mod);
238238
if (ret < 0) {
239239
tr_err(&userspace_proxy_tr, "Failed to pin cpu, error: %d", ret);
240-
MOD_DBG(mod);
240+
DEBUG(mod);
241241
goto done;
242242
}
243243

244244
ret = k_work_user_submit_to_queue(&worker.work_queue, &user_ctx->work_item->work_item);
245-
MOD_DBG(mod);
245+
DEBUG(mod);
246246
if (ret < 0) {
247247
tr_err(&userspace_proxy_tr, "Submit to queue error: %d", ret);
248-
MOD_DBG(mod);
248+
DEBUG(mod);
249249
goto done;
250250
}
251251
#else
252252
assert(event);
253-
MOD_DBG(mod);
253+
DEBUG(mod);
254254
k_event_post(event, DP_TASK_EVENT_IPC);
255-
MOD_DBG(mod);
255+
DEBUG(mod);
256256
#endif
257257

258258
/* Timeout value is aligned with the ipc_wait_for_compound_msg function */
259259
if (!k_event_wait_safe(event, DP_TASK_EVENT_IPC_DONE, false,
260260
Z_TIMEOUT_US(250 * 20))) {
261261
tr_err(&userspace_proxy_tr, "IPC processing timedout.");
262-
MOD_DBG(mod);
262+
DEBUG(mod);
263263
ret = -ETIMEDOUT;
264264
}
265-
MOD_DBG(mod);
265+
DEBUG(mod);
266266

267267
done:
268268
if (ipc_payload_access) {
269269
ret2 = k_mem_domain_remove_partition(user_ctx->comp_dom, &ipc_part);
270-
MOD_DBG(mod);
270+
DEBUG(mod);
271271
if (ret2 < 0) {
272272
tr_err(&userspace_proxy_tr, "Mailbox remove from domain error: %d", ret);
273-
MOD_DBG(mod);
273+
DEBUG(mod);
274274

275275
if (!ret)
276276
ret = ret2;
277277
}
278278
}
279-
MOD_DBG(mod);
279+
DEBUG(mod);
280280

281281
return ret;
282282
}
@@ -403,7 +403,7 @@ static int userspace_proxy_start_agent(struct userspace_context *user_ctx,
403403
}
404404
return 0;
405405
}
406-
406+
struct userspace_context *dbg_ctx;
407407
int userspace_proxy_create(struct userspace_context **user_ctx, const struct comp_driver *drv,
408408
const struct sof_man_module *manifest, system_agent_start_fn agent_fn,
409409
const struct system_agent_params *agent_params,
@@ -418,7 +418,7 @@ int userspace_proxy_create(struct userspace_context **user_ctx, const struct com
418418
context = k_heap_alloc(drv->user_heap, sizeof(struct userspace_context), K_FOREVER);
419419
if (!context)
420420
return -ENOMEM;
421-
421+
dbg_ctx = context;
422422
context->dp_event = NULL;
423423

424424
/* Allocate memory domain struct */
@@ -499,43 +499,43 @@ void userspace_proxy_destroy(const struct comp_driver *drv, struct userspace_con
499499
static int userspace_proxy_init(struct processing_module *mod)
500500
{
501501
struct module_params *params = user_work_get_params(mod->user_ctx);
502-
MOD_DBG(mod);
502+
DEBUG(mod);
503503
int ret;
504504

505505
comp_dbg(mod->dev, "start");
506-
MOD_DBG(mod);
506+
DEBUG(mod);
507507

508508
#if IS_ENABLED(CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD)
509509
/* Start the system agent, if provided. Params is already filled by
510510
* the userspace_proxy_start_agent function.
511511
*/
512512
if (params->ext.agent.start_fn) {
513-
MOD_DBG(mod);
513+
DEBUG(mod);
514514
ret = userspace_proxy_invoke(mod->user_ctx, USER_PROXY_MOD_CMD_AGENT_START, true);
515-
MOD_DBG(mod);
515+
DEBUG(mod);
516516
if (ret)
517517
return ret;
518518

519519
if (params->ext.agent.start_fn == system_agent_start) {
520520
module_set_private_data(mod, (void *)params->ext.agent.out_interface);
521-
MOD_DBG(mod);
521+
DEBUG(mod);
522522
} else {
523523
mod->user_ctx->interface = params->ext.agent.out_interface;
524-
MOD_DBG(mod);
524+
DEBUG(mod);
525525
}
526526
}
527-
MOD_DBG(mod);
527+
DEBUG(mod);
528528
#endif
529529

530530
params->mod = mod;
531-
MOD_DBG(mod);
531+
DEBUG(mod);
532532
ret = userspace_proxy_invoke(mod->user_ctx, USER_PROXY_MOD_CMD_INIT, true);
533-
MOD_DBG(mod);
533+
DEBUG(mod);
534534
if (ret)
535535
return ret;
536536

537537
/* Return status from module code operation. */
538-
MOD_DBG(mod);
538+
DEBUG(mod);
539539
return params->status;
540540
}
541541

src/audio/module_adapter/module/generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL);
3838

39-
/* Global fallback variables for MOD_DBG when mod is NULL */
39+
/* Global fallback variables for DEBUG when mod is NULL */
4040
uint32_t mod_dbg_global_line;
4141
const char *mod_dbg_global_file;
4242

src/include/module/module/base.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <stdint.h>
1313
#include <stddef.h>
1414
#include <stdbool.h>
15+
#include <string.h>
1516

1617
#include "interface.h"
1718
#include "../ipc4/base-config.h"
@@ -27,9 +28,17 @@ extern uint32_t mod_dbg_global_line;
2728
extern const char *mod_dbg_global_file;
2829

2930
#define MOD_DBG(mod) do { \
30-
if (mod) { \
3131
(mod)->line = __LINE__; \
3232
(mod)->file = __FILE__; \
33+
} while (0)
34+
35+
#define MOD_DBG_FILE_BUF_SIZE 150
36+
37+
#define DEBUG(mod) do { \
38+
if (mod) { \
39+
(mod)->line = __LINE__; \
40+
strncpy((mod)->dbg_file, __FILE__, MOD_DBG_FILE_BUF_SIZE - 1); \
41+
(mod)->dbg_file[MOD_DBG_FILE_BUF_SIZE - 1] = '\0'; \
3342
} else { \
3443
mod_dbg_global_line = __LINE__; \
3544
mod_dbg_global_file = __FILE__; \
@@ -112,6 +121,7 @@ struct processing_module {
112121
uint32_t period_bytes; /** pipeline period bytes */
113122
uint32_t line;
114123
const char *file;
124+
char dbg_file[MOD_DBG_FILE_BUF_SIZE];
115125
/*
116126
* Fields below can only be accessed by the SOF and must be moved to a new structure.
117127
* Below #ifdef is a temporary solution used until work on separating a common interface

0 commit comments

Comments
 (0)