From 8dcf84eccd0e084f6dfbf67e4e200a13b19edfbe Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 24 Nov 2026 18:04:32 +0200 Subject: [PATCH] ASoC: SOF: ipc4-loader: Add debugfs file to list the firmware modules Add a fw_modules debugfs file to list the library ID, module ID, UUID and name of the modules in the basefw and the loaded libraries. Example: # cat /sys/kernel/debug/sof/fw_modules lib | module | UUID | name 0 | 0 | 2B79E4F3-4675-F649-89DF-3BC194A91AEB | BRNGUP 0 | 1 | D406D134-C3C1-402C-8AEC-6821C0C2B0E6 | COLD .. 0 | 12 | 0D116EA6-9150-46DE-98B8-B2B3A791DA29 | STFTPROC 1 | 0 | B0CDCD9E-EF8B-404F-8480-0F287FC9D44D | IIR 1 | 1 | 93446E12-1864-4E04-AFE0-3B1D778FFB79 | FIR 1 | 2 | 99F7166D-372C-43EF-81F6-22007AA15F03 | ARIA ... Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc4-loader.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sound/soc/sof/ipc4-loader.c b/sound/soc/sof/ipc4-loader.c index 1da51f7490e579..af8f0bfe2dc2af 100644 --- a/sound/soc/sof/ipc4-loader.c +++ b/sound/soc/sof/ipc4-loader.c @@ -5,7 +5,9 @@ // // Copyright(c) 2022 Intel Corporation +#include #include +#include #include #include #include @@ -142,6 +144,37 @@ static ssize_t sof_ipc4_fw_parse_ext_man(struct snd_sof_dev *sdev, return ext_man_hdr->len; } +/* + * fw_lib_xa is RCU safe for readers, entries are fully initialized before + * they are inserted and they are never removed while the device is bound. + * Only the data copied from the manifest may be printed here: fw_lib->name and + * fw_mod_cfg point to the firmware file, which is released in sof_ipc4_exit() + * before the debugfs tree is removed. + */ +static int sof_ipc4_fw_modules_show(struct seq_file *s, void *unused) +{ + struct sof_ipc4_fw_data *ipc4_data = s->private; + struct sof_ipc4_fw_library *fw_lib; + unsigned long lib_id; + int i; + + seq_printf(s, "lib | module | %-36s | name\n", "UUID"); + + xa_for_each(&ipc4_data->fw_lib_xa, lib_id, fw_lib) { + for (i = 0; i < fw_lib->num_modules; i++) { + struct sof_man4_module *entry = &fw_lib->modules[i].man4_module_entry; + u32 mod_id = entry->id & GENMASK(SOF_IPC4_MOD_LIB_ID_SHIFT - 1, 0); + + seq_printf(s, "%-3lu | %-6u | %pUL | %.*s\n", lib_id, mod_id, + &entry->uuid, (int)sizeof(entry->name), + entry->name); + } + } + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(sof_ipc4_fw_modules); + static size_t sof_ipc4_fw_parse_basefw_ext_man(struct snd_sof_dev *sdev) { struct sof_ipc4_fw_data *ipc4_data = sdev->private; @@ -173,6 +206,10 @@ static size_t sof_ipc4_fw_parse_basefw_ext_man(struct snd_sof_dev *sdev) ret = xa_insert(&ipc4_data->fw_lib_xa, 0, fw_lib, GFP_KERNEL); if (ret) return ret; + + /* removed with the SOF debugfs root */ + debugfs_create_file("fw_modules", 0444, sdev->debugfs_root, ipc4_data, + &sof_ipc4_fw_modules_fops); } return payload_offset;