Skip to content

Commit 07c0036

Browse files
author
Jyri Sarha
committed
zephyr: shell: Add sof module_heap_usage command
Adds new command to sof sub-command set. The new command, module_heap_usage, prints out all active component ids and their heap memory usage allocated through module API. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent f0cdbde commit 07c0036

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

zephyr/sof_shell.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <rtos/sof.h> /* sof_get() */
99
#include <sof/schedule/ll_schedule_domain.h>
10+
#include <sof/audio/module_adapter/module/generic.h>
1011

1112
#include <zephyr/kernel.h>
1213
#include <zephyr/sys/printk.h>
@@ -40,11 +41,38 @@ static int cmd_sof_test_inject_sched_gap(const struct shell *sh,
4041
return 0;
4142
}
4243

44+
static int cmd_sof_module_heap_usage(const struct shell *sh,
45+
size_t argc, char *argv[])
46+
{
47+
struct ipc *ipc = sof_get()->ipc;
48+
struct list_item *clist, *_clist;
49+
struct ipc_comp_dev *icd;
50+
51+
if (!ipc) {
52+
shell_print(sh, "No IPC");
53+
return 0;
54+
}
55+
56+
list_for_item_safe(clist, _clist, &ipc->comp_list) {
57+
icd = container_of(clist, struct ipc_comp_dev, list);
58+
if (icd->type != COMP_TYPE_COMPONENT)
59+
continue;
60+
61+
shell_print(sh, "component id 0x%08x\t%8zu bytes", icd->id,
62+
module_adapter_heap_usage(icd->cd));
63+
}
64+
return 0;
65+
}
66+
4367
SHELL_STATIC_SUBCMD_SET_CREATE(sof_commands,
4468
SHELL_CMD(test_inject_sched_gap, NULL,
4569
"Inject a gap to audio scheduling\n",
4670
cmd_sof_test_inject_sched_gap),
4771

72+
SHELL_CMD(module_heap_usage, NULL,
73+
"Print heap memory usage of each module\n",
74+
cmd_sof_module_heap_usage),
75+
4876
SHELL_SUBCMD_SET_END
4977
);
5078

0 commit comments

Comments
 (0)