Skip to content

Commit 211db10

Browse files
author
Jyri Sarha
committed
ASoC: SOF: IPC4: Simple debugfs file for telemetry2 debug window slot
The "telemetry2" debugfs file simply maps the telemetry2 debug slot as a debugfs file. The decoding is left to user-space tools. The telemetry2 debug window contents is encoded in SOF FW code found under sof/src/debug/telemetry directory in the SOF FW sources. Signed-off-by: Jyri Sarha <[email protected]>
1 parent 5128356 commit 211db10

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

sound/soc/sof/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ snd-sof-objs += ipc3.o ipc3-loader.o ipc3-topology.o ipc3-control.o ipc3-pcm.o\
1111
endif
1212
ifneq ($(CONFIG_SND_SOC_SOF_IPC4),)
1313
snd-sof-objs += ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o\
14-
ipc4-mtrace.o ipc4-telemetry.o
14+
ipc4-mtrace.o ipc4-telemetry.o ipc4-telemetry2.o
1515
endif
1616

1717
# SOF client support

sound/soc/sof/ipc4-telemetry2.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
//
3+
// Copyright(c) 2024 Intel Corporation.
4+
5+
#include <linux/debugfs.h>
6+
#include <linux/io.h>
7+
#include <linux/pm_runtime.h>
8+
#include <sound/sof/debug.h>
9+
#include <sound/sof/ipc4/header.h>
10+
#include "sof-priv.h"
11+
#include "ops.h"
12+
#include "ipc4-telemetry2.h"
13+
#include "ipc4-priv.h"
14+
15+
static ssize_t sof_telemetry2_entry_read(struct file *file, char __user *buffer,
16+
size_t count, loff_t *ppos)
17+
{
18+
struct snd_sof_dfsentry *dfse = file->private_data;
19+
struct snd_sof_dev *sdev = dfse->sdev;
20+
u32 type = SOF_IPC4_DEBUG_SLOT_TELEMETRY2;
21+
loff_t pos = *ppos;
22+
size_t size_ret;
23+
u32 offset;
24+
u8 *buf;
25+
26+
if (pos < 0)
27+
return -EINVAL;
28+
if (pos >= SOF_IPC4_DEBUG_SLOT_SIZE || !count)
29+
return 0;
30+
if (count > SOF_IPC4_DEBUG_SLOT_SIZE - pos)
31+
count = SOF_IPC4_DEBUG_SLOT_SIZE - pos;
32+
33+
offset = sof_ipc4_find_debug_slot_offset_by_type(sdev, type);
34+
if (!offset)
35+
return -EFAULT;
36+
37+
buf = kzalloc(SOF_IPC4_DEBUG_SLOT_SIZE, GFP_KERNEL);
38+
if (!buf)
39+
return -ENOMEM;
40+
41+
sof_mailbox_read(sdev, offset, buf, SOF_IPC4_DEBUG_SLOT_SIZE);
42+
size_ret = copy_to_user(buffer, buf + pos, count);
43+
if (size_ret) {
44+
kfree(buf);
45+
return -EFAULT;
46+
}
47+
48+
*ppos = pos + count;
49+
kfree(buf);
50+
51+
return count;
52+
}
53+
54+
static const struct file_operations sof_telemetry2_fops = {
55+
.open = simple_open,
56+
.read = sof_telemetry2_entry_read,
57+
.llseek = default_llseek,
58+
};
59+
60+
void sof_ipc4_create_telemetry2_debugfs_node(struct snd_sof_dev *sdev)
61+
{
62+
struct snd_sof_dfsentry *dfse;
63+
64+
dfse = devm_kzalloc(sdev->dev, sizeof(*dfse), GFP_KERNEL);
65+
if (!dfse)
66+
return;
67+
68+
dfse->type = SOF_DFSENTRY_TYPE_IOMEM;
69+
dfse->size = SOF_IPC4_DEBUG_SLOT_SIZE;
70+
dfse->access_type = SOF_DEBUGFS_ACCESS_ALWAYS;
71+
dfse->sdev = sdev;
72+
73+
list_add(&dfse->list, &sdev->dfsentry_list);
74+
75+
debugfs_create_file("telemetry2", 0444, sdev->debugfs_root, dfse, &sof_telemetry2_fops);
76+
}

sound/soc/sof/ipc4-telemetry2.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright(c) 2024 Intel Corporation.
4+
*/
5+
6+
#ifndef __SOUND_SOC_SOF_IPC4_TELEMETRY2_H
7+
#define __SOUND_SOC_SOF_IPC4_TELEMETRY2_H
8+
9+
void sof_ipc4_create_telemetry2_debugfs_node(struct snd_sof_dev *sdev);
10+
11+
#endif

sound/soc/sof/ipc4.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "ipc4-fw-reg.h"
1717
#include "ipc4-priv.h"
1818
#include "ipc4-telemetry.h"
19+
#include "ipc4-telemetry2.h"
1920
#include "ops.h"
2021

2122
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
582583

583584
sof_ipc4_create_exception_debugfs_node(sdev);
584585

586+
sof_ipc4_create_telemetry2_debugfs_node(sdev);
587+
585588
return sof_ipc4_init_msg_memory(sdev);
586589
}
587590

0 commit comments

Comments
 (0)