ASoC: SOF: Add 'memory_info' file to debugfs
Subsystems (3)
Kai Vehmanen
reviewercover ASoC: SOF: Add 'memory_info' file to debugfs
Series that adds a new debugfs entry to query status of SOF FW memory allocation at runtime. Information on used and free memory is shown separately for each zone. A new IPC message is added for this purpose and ABI minor revision is bumped accordingly to 3.18.
To implement this, additional FW configuration data needs to be parsed from the firmware file and this is done in the first patch.
A few cleanups to surrounding code is done in separate patches.
Karol Trzcinski (4):
ASoC: SOF: ext_manifest: Parse firmware config dictionary
ASoC: SOF: Improve code alignment in header.h
ASoC: SOF: Change section comment for SOF_IPC_TEST_
ASoC: SOF: Add memory_info file to debugfs
include/sound/sof/debug.h | 41 +++++++++++ include/sound/sof/ext_manifest.h | 20 ++++++ include/sound/sof/header.h | 10 ++- include/uapi/sound/sof/abi.h | 2 +- sound/soc/sof/debug.c | 117 +++++++++++++++++++++++++++++++ sound/soc/sof/ipc.c | 9 +++ sound/soc/sof/loader.c | 51 ++++++++++++++ sound/soc/sof/sof-priv.h | 2 + 8 files changed, 248 insertions(+), 4 deletions(-) create mode 100644 include/sound/sof/debug.h
Signature · 1 line
2.28.0
Kai Vehmanen
reviewerPATCH 1/4 ASoC: SOF: ext_manifest: Parse firmware config dictionary
From: Karol Trzcinski <[email protected]>
Values given in this dictionary describes used firmware configuration, like feature availability, buffer size limits and similar properties.
--- include/sound/sof/ext_manifest.h | 19 +++++++++++++++ sound/soc/sof/loader.c | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
include/sound/sof/ext_manifest.h +19 -0
@@ -61,6 +61,7 @@ enum sof_ext_man_elem_type {SOF_EXT_MAN_ELEM_WINDOW =SOF_IPC_EXT_WINDOW ,SOF_EXT_MAN_ELEM_CC_VERSION =SOF_IPC_EXT_CC_INFO ,SOF_EXT_MAN_ELEM_DBG_ABI =SOF_IPC_EXT_USER_ABI_INFO , + SOF_EXT_MAN_ELEM_CONFIG_DATA = 5, /**< ABI3.17 */ };/* extended manifest element header */
@@ -99,4 +100,22 @@ struct ext_man_dbg_abi { struct sof_ipc_user_abi_version dbg_abi; } __packed; +/* EXT_MAN_ELEM_CONFIG_DATA elements identificators, ABI3.17 */ +enum config_elem_type { +SOF_EXT_MAN_CONFIG_EMPTY =0 , +SOF_EXT_MAN_CONFIG_IPC_MSG_SIZE =1 , +}; + +struct sof_config_elem { +uint32_t token; +uint32_t value; +} __packed; + +/* firmware configuration information */ +struct sof_ext_man_config_data { +struct sof_ext_man_elem_header hdr; + +struct sof_config_elem elems[]; +} __packed; +#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */
sound/soc/sof/loader.c +41 -0
53 lines not on this page · raw message
Signature · 1 line
2.28.0
Kai Vehmanen
reviewerPATCH 2/4 ASoC: SOF: Improve code alignment in header.h
In reply to Kai VehmanenFrom: Karol Trzcinski <[email protected]>
Each define value in series should be aligned and tabs should be used instead of spaces to follow code-style.
--- include/sound/sof/header.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/sound/sof/header.h +3 -3
@@ -49,7 +49,7 @@#define SOF_IPC_FW_READY SOF_GLB_TYPE(0x7U)#define SOF_IPC_GLB_DAI_MSG SOF_GLB_TYPE(0x8U)#define SOF_IPC_GLB_TRACE_MSG SOF_GLB_TYPE(0x9U) -#define SOF_IPC_GLB_GDB_DEBUG SOF_GLB_TYPE(0xAU) +#define SOF_IPC_GLB_GDB_DEBUG SOF_GLB_TYPE(0xAU)#define SOF_IPC_GLB_TEST_MSG SOF_GLB_TYPE(0xBU)#define SOF_IPC_GLB_PROBE SOF_GLB_TYPE(0xCU)
@@ -109,7 +109,7 @@#define SOF_IPC_PROBE_DMA_ADD SOF_CMD_TYPE(0x003)#define SOF_IPC_PROBE_DMA_INFO SOF_CMD_TYPE(0x004)#define SOF_IPC_PROBE_DMA_REMOVE SOF_CMD_TYPE(0x005) -#define SOF_IPC_PROBE_POINT_ADD SOF_CMD_TYPE(0x006) +#define SOF_IPC_PROBE_POINT_ADD SOF_CMD_TYPE(0x006)#define SOF_IPC_PROBE_POINT_INFO SOF_CMD_TYPE(0x007)#define SOF_IPC_PROBE_POINT_REMOVE SOF_CMD_TYPE(0x008)
@@ -119,7 +119,7 @@#define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003)/* debug */ -#define SOF_IPC_TEST_IPC_FLOOD SOF_CMD_TYPE(0x001) +#define SOF_IPC_TEST_IPC_FLOOD SOF_CMD_TYPE(0x001)/* Get message component id */ #define SOF_IPC_MESSAGE_ID (x) ((x) & 0xffff)
Signature · 1 line
2.28.0
Kai Vehmanen
reviewerPATCH 3/4 ASoC: SOF: Change section comment for SOF_IPC_TEST_
In reply to Kai VehmanenFrom: Karol Trzcinski <[email protected]>
Section comment should be coherent with IPC prefix from define names.
--- include/sound/sof/header.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/sof/header.h +1 -1
@@ -118,7 +118,7 @@#define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002)#define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003) -/* debug */ +/* test */ #define SOF_IPC_TEST_IPC_FLOOD SOF_CMD_TYPE(0x001)/* Get message component id */
Signature · 1 line
2.28.0
Kai Vehmanen
reviewerPATCH 4/4 ASoC: SOF: Add `memory_info` file to debugfs
In reply to Kai VehmanenFrom: Karol Trzcinski <[email protected]>
This file content describes memory allocation status at run-time, typically to detect memory leaks.
--- include/sound/sof/debug.h | 41 +++++++++++ include/sound/sof/ext_manifest.h | 1 + include/sound/sof/header.h | 4 ++ include/uapi/sound/sof/abi.h | 2 +- sound/soc/sof/debug.c | 117 +++++++++++++++++++++++++++++++ sound/soc/sof/ipc.c | 9 +++ sound/soc/sof/loader.c | 10 +++ sound/soc/sof/sof-priv.h | 2 + 8 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 include/sound/sof/debug.h
include/sound/sof/debug.h new file +41 -0
@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* Copyright(c) 2020 Intel Corporation. All rights reserved. +* +* Author: Karol Trzcinski <[email protected]> +*/ + +#ifndef __INCLUDE_SOUND_SOF_DEBUG_H__ +#define __INCLUDE_SOUND_SOF_DEBUG_H__ + +#include <sound/sof/header.h> + +/** ABI3.18 */ +enum sof_ipc_dbg_mem_zone { +SOF_IPC_MEM_ZONE_SYS =0 ,/**< System zone */ +SOF_IPC_MEM_ZONE_SYS_RUNTIME =1 ,/**< System-runtime zone */ +SOF_IPC_MEM_ZONE_RUNTIME =2 ,/**< Runtime zone */ +SOF_IPC_MEM_ZONE_BUFFER =3 ,/**< Buffer zone */ +}; + +/** ABI3.18 */ +struct sof_ipc_dbg_mem_usage_elem { +uint32_t zone;/**< see sof_ipc_dbg_mem_zone */ +uint32_t id;/**< heap index within zone */ +uint32_t used;/**< number of bytes used in zone */ +uint32_t free;/**< number of bytes free to use within zone */ +uint32_t reserved;/**< for future use */ +} __packed; + +/** ABI3.18 */ +struct sof_ipc_dbg_mem_usage { +struct sof_ipc_reply rhdr;/**< generic IPC reply header */ +uint32_t reserved[4 ];/**< reserved for future use */ +uint32_t num_elems;/**< elems[] counter */ +struct sof_ipc_dbg_mem_usage_elem elems[];/**< memory usage information */ +} __packed; + +#endif
include/sound/sof/ext_manifest.h +1 -0
@@ -104,6 +104,7 @@ struct ext_man_dbg_abi {enum config_elem_type {SOF_EXT_MAN_CONFIG_EMPTY =0 ,SOF_EXT_MAN_CONFIG_IPC_MSG_SIZE =1 , +SOF_EXT_MAN_CONFIG_MEMORY_USAGE_SCAN =2 ,/**< ABI 3.18 */ };struct sof_config_elem {
include/sound/sof/header.h +4 -0
@@ -52,6 +52,7 @@#define SOF_IPC_GLB_GDB_DEBUG SOF_GLB_TYPE(0xAU)#define SOF_IPC_GLB_TEST_MSG SOF_GLB_TYPE(0xBU)#define SOF_IPC_GLB_PROBE SOF_GLB_TYPE(0xCU) +#define SOF_IPC_GLB_DEBUG SOF_GLB_TYPE(0xDU)/* * DSP Command Message Types
@@ -118,6 +119,9 @@#define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002)#define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003) +/* debug */ +#define SOF_IPC_DEBUG_MEM_USAGE SOF_CMD_TYPE(0x001) +/* test */ #define SOF_IPC_TEST_IPC_FLOOD SOF_CMD_TYPE(0x001)
include/uapi/sound/sof/abi.h +1 -1
@@ -26,7 +26,7 @@/* SOF ABI version major, minor and patch numbers */ #define SOF_ABI_MAJOR 3 -#define SOF_ABI_MINOR 17 +#define SOF_ABI_MINOR 18#define SOF_ABI_PATCH 0/* SOF ABI version number. Format within 32bit word is MMmmmppp */
sound/soc/sof/debug.c +117 -0
129 lines not on this page · raw message
sound/soc/sof/ipc.c +9 -0
@@ -181,6 +181,15 @@ static void ipc_log_header(struct device *dev, u8 *text, u32 cmd) str2 ="unknown type" ;break ; }break ; +case SOF_IPC_GLB_DEBUG : + str ="GLB_DEBUG" ; +switch (type) { +case SOF_IPC_DEBUG_MEM_USAGE : + str2 ="MEM_USAGE" ;break ; +default : + str2 ="unknown type" ;break ; + } +break ;default : str ="unknown GLB command" ;break ; }
sound/soc/sof/loader.c +10 -0
@@ -205,6 +205,7 @@ static int ext_man_get_config_data(struct snd_sof_dev *sdev,const struct sof_config_elem *elem;int elems_counter;int elems_size; +int ret =0 ;int i;/* calculate elements counter */
@@ -225,11 +226,20 @@ static int ext_man_get_config_data(struct snd_sof_dev *sdev,case SOF_EXT_MAN_CONFIG_IPC_MSG_SIZE :/* TODO: use ipc msg size from config data */ break ; +case SOF_EXT_MAN_CONFIG_MEMORY_USAGE_SCAN : +if (sdev->first_boot && elem->value) + ret =snd_sof_dbg_memory_info_init (sdev); +break ;default :dev_info (sdev->dev,"Unknown firmware configuration token %d value %d" , elem->token, elem->value);break ; } +if (ret <0 ) { +dev_err (sdev->dev,"error: processing sof_ext_man_config_data failed for token %d value 0x%x, %d\n" , + elem->token, elem->value, ret); +return ret; + } }return 0 ;
sound/soc/sof/sof-priv.h +2 -0
@@ -290,6 +290,7 @@ enum sof_debugfs_access_type {/* FS entry for debug files that can expose DSP memories, registers */ struct snd_sof_dfsentry {size_t size; +size_t buf_data_size;/* length of buffered data for file read operation */ enum sof_dfsentry_type type;/* * access_type specifies if the
@@ -523,6 +524,7 @@ void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code, void *stack, size_t stack_words);int snd_sof_init_trace_ipc (struct snd_sof_dev *sdev);void snd_sof_handle_fw_exception (struct snd_sof_dev *sdev); +int snd_sof_dbg_memory_info_init (struct snd_sof_dev *sdev);/* * Platform specific ops.
Signature · 1 line
2.28.0
Mark Brown
maintainerQuoted 9 lines · Kai Vehmanen
Series that adds a new debugfs entry to query status of SOF FW memory allocation at runtime. Information on used and free memory is shown separately for each zone. A new IPC message is added for this purpose and ABI minor revision is bumped accordingly to 3.18.
To implement this, additional FW configuration data needs to be parsed from the firmware file and this is done in the first patch.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: SOF: ext_manifest: Parse firmware config dictionary
commit: 7f09f79d5cb13186b0f422cf2e1c711c88c92195
[2/4] ASoC: SOF: Improve code alignment in header.h
commit: 2e4f3f9141cc626147eaf6fbb8a92f17fd069553
[3/4] ASoC: SOF: Change section comment for SOF_IPC_TEST_
commit: 6dd958955d3053a9c50353e39671622af4b8fba2
[4/4] ASoC: SOF: Add `memory_info` file to debugfs
commit: 5b10b62989219aa527ee4fa555d1995a3b70981bAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark