diff --git a/include/sound/sof/ipc4/header.h b/include/sound/sof/ipc4/header.h index 1eb538e18236ae..84e410c8949eee 100644 --- a/include/sound/sof/ipc4/header.h +++ b/include/sound/sof/ipc4/header.h @@ -536,6 +536,7 @@ struct sof_ipc4_notify_resource_data { #define SOF_IPC4_DEBUG_SLOT_DEBUG_LOG 0x474f4c00 /* byte 0: core ID */ #define SOF_IPC4_DEBUG_SLOT_GDB_STUB 0x42444700 #define SOF_IPC4_DEBUG_SLOT_TELEMETRY 0x4c455400 +#define SOF_IPC4_DEBUG_SLOT_TELEMETRY2 0x4c455500 #define SOF_IPC4_DEBUG_SLOT_BROKEN 0x44414544 /** diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index 3624124575afdf..4e4360f29937c9 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -11,7 +11,7 @@ snd-sof-objs += ipc3.o ipc3-loader.o ipc3-topology.o ipc3-control.o ipc3-pcm.o\ endif ifneq ($(CONFIG_SND_SOC_SOF_IPC4),) snd-sof-objs += ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o\ - ipc4-mtrace.o ipc4-telemetry.o + ipc4-mtrace.o ipc4-telemetry.o ipc4-telemetry2.o endif # SOF client support diff --git a/sound/soc/sof/ipc4-telemetry2.c b/sound/soc/sof/ipc4-telemetry2.c new file mode 100644 index 00000000000000..e9936bbb58c5da --- /dev/null +++ b/sound/soc/sof/ipc4-telemetry2.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2024 Intel Corporation. + +#include +#include +#include +#include +#include +#include "sof-priv.h" +#include "ops.h" +#include "ipc4-telemetry2.h" +#include "ipc4-priv.h" + +static ssize_t sof_telemetry2_entry_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct snd_sof_dfsentry *dfse = file->private_data; + struct snd_sof_dev *sdev = dfse->sdev; + u32 type = SOF_IPC4_DEBUG_SLOT_TELEMETRY2; + loff_t pos = *ppos; + size_t size_ret; + u32 offset; + u8 *buf; + + if (pos < 0) + return -EINVAL; + if (pos >= SOF_IPC4_DEBUG_SLOT_SIZE || !count) + return 0; + if (count > SOF_IPC4_DEBUG_SLOT_SIZE - pos) + count = SOF_IPC4_DEBUG_SLOT_SIZE - pos; + + offset = sof_ipc4_find_debug_slot_offset_by_type(sdev, type); + if (!offset) + return -EFAULT; + + buf = kzalloc(SOF_IPC4_DEBUG_SLOT_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + sof_mailbox_read(sdev, offset, buf, SOF_IPC4_DEBUG_SLOT_SIZE); + size_ret = copy_to_user(buffer, buf + pos, count); + if (size_ret) { + kfree(buf); + return -EFAULT; + } + + *ppos = pos + count; + kfree(buf); + + return count; +} + +static const struct file_operations sof_telemetry2_fops = { + .open = simple_open, + .read = sof_telemetry2_entry_read, + .llseek = default_llseek, +}; + +void sof_ipc4_create_telemetry2_debugfs_node(struct snd_sof_dev *sdev) +{ + struct snd_sof_dfsentry *dfse; + + dfse = devm_kzalloc(sdev->dev, sizeof(*dfse), GFP_KERNEL); + if (!dfse) + return; + + dfse->type = SOF_DFSENTRY_TYPE_IOMEM; + dfse->size = SOF_IPC4_DEBUG_SLOT_SIZE; + dfse->access_type = SOF_DEBUGFS_ACCESS_ALWAYS; + dfse->sdev = sdev; + + list_add(&dfse->list, &sdev->dfsentry_list); + + debugfs_create_file("telemetry2", 0444, sdev->debugfs_root, dfse, &sof_telemetry2_fops); +} diff --git a/sound/soc/sof/ipc4-telemetry2.h b/sound/soc/sof/ipc4-telemetry2.h new file mode 100644 index 00000000000000..1bac1e0e45b4fa --- /dev/null +++ b/sound/soc/sof/ipc4-telemetry2.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright(c) 2024 Intel Corporation. + */ + +#ifndef __SOUND_SOC_SOF_IPC4_TELEMETRY2_H +#define __SOUND_SOC_SOF_IPC4_TELEMETRY2_H + +void sof_ipc4_create_telemetry2_debugfs_node(struct snd_sof_dev *sdev); + +#endif diff --git a/sound/soc/sof/ipc4.c b/sound/soc/sof/ipc4.c index ac5c6bc66d2ab7..5d1f4647263194 100644 --- a/sound/soc/sof/ipc4.c +++ b/sound/soc/sof/ipc4.c @@ -16,6 +16,7 @@ #include "ipc4-fw-reg.h" #include "ipc4-priv.h" #include "ipc4-telemetry.h" +#include "ipc4-telemetry2.h" #include "ops.h" static const struct sof_ipc4_fw_status { @@ -582,6 +583,8 @@ static int ipc4_fw_ready(struct snd_sof_dev *sdev, struct sof_ipc4_msg *ipc4_msg sof_ipc4_create_exception_debugfs_node(sdev); + sof_ipc4_create_telemetry2_debugfs_node(sdev); + return sof_ipc4_init_msg_memory(sdev); }