Repository navigation
Debug stream debugfs #5154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jsarha
wants to merge
5
commits into
thesofproject:topic/sof-dev
Choose a base branch
from
jsarha:debug-stream-debugfs
base: topic/sof-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Debug stream debugfs #5154
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bae7f6e
ASoC: SOF: ipc4: Add sof_ipc4_create_debug_slot_ro_debugfs_node()
c828f4d
ASoC: SOF: IPC4: Add debug-stream debug slot type
bb27a0e
ASoC: SOF: ipc4: Maps debug-stream debug window slot as ro debugfs file
40d5cb5
ASoC: SOF: ipc4: Use generic function for mapping "exception" debugfs…
42d99ba
ASoC: SOF: ipc4: rate-limit debug slot lookup failure message
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // 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) 2024-2025 Intel Corporation. | ||
| // | ||
|
|
||
| #include <linux/debugfs.h> | ||
| #include <linux/io.h> | ||
| #include <linux/pm_runtime.h> | ||
| #include <sound/sof/debug.h> | ||
| #include <sound/sof/ipc4/header.h> | ||
| #include "sof-priv.h" | ||
| #include "ops.h" | ||
| #include "ipc4-priv.h" | ||
|
|
||
| struct debug_slot_fs_ud { | ||
| struct snd_sof_dfsentry dfse; | ||
| u32 slot_type; | ||
| size_t data_offset; | ||
| }; | ||
|
|
||
| static ssize_t sof_debug_slot_debugfs_entry_read(struct file *file, char __user *buffer, | ||
| size_t count, loff_t *ppos) | ||
| { | ||
| struct debug_slot_fs_ud *ud = file->private_data; | ||
| struct snd_sof_dfsentry *dfse = &ud->dfse; | ||
| struct snd_sof_dev *sdev = dfse->sdev; | ||
| size_t doffset = ud->data_offset; | ||
| u32 type = ud->slot_type; | ||
| loff_t pos = *ppos; | ||
| size_t exposed_size; | ||
| size_t size_ret; | ||
| u32 offset; | ||
| u8 *buf; | ||
|
|
||
| if (doffset >= SOF_IPC4_DEBUG_SLOT_SIZE) | ||
| return -EINVAL; | ||
|
|
||
| exposed_size = SOF_IPC4_DEBUG_SLOT_SIZE - doffset; | ||
|
|
||
| if (pos < 0) | ||
| return -EINVAL; | ||
| if (pos >= exposed_size || !count) | ||
| return 0; | ||
| if (count > exposed_size - pos) | ||
| count = exposed_size - pos; | ||
|
|
||
| offset = sof_ipc4_find_debug_slot_offset_by_type(sdev, type); | ||
| if (!offset) | ||
| return -EFAULT; | ||
|
|
||
| buf = kzalloc(exposed_size, GFP_KERNEL); | ||
| if (!buf) | ||
| return -ENOMEM; | ||
|
|
||
| sof_mailbox_read(sdev, offset + doffset, buf, exposed_size); | ||
| size_ret = copy_to_user(buffer, buf + pos, count); | ||
| kfree(buf); | ||
| if (size_ret) | ||
| return -EFAULT; | ||
|
|
||
| *ppos = pos + count; | ||
|
|
||
| return count; | ||
| } | ||
|
|
||
| static const struct file_operations sof_debug_stream_fops = { | ||
| .open = simple_open, | ||
| .read = sof_debug_slot_debugfs_entry_read, | ||
| .llseek = default_llseek, | ||
| }; | ||
|
|
||
| void sof_ipc4_create_debug_slot_ro_debugfs_node(struct snd_sof_dev *sdev, u32 slot_type, | ||
| size_t data_offset, const char *name) | ||
| { | ||
| struct debug_slot_fs_ud *ud; | ||
| size_t exposed_size; | ||
|
|
||
| if (data_offset >= SOF_IPC4_DEBUG_SLOT_SIZE) | ||
| return; | ||
|
|
||
| exposed_size = SOF_IPC4_DEBUG_SLOT_SIZE - data_offset; | ||
|
|
||
| /* | ||
| * Reject partial descriptor 15 if this interface must not cross the | ||
| * end of page 0 into the next slot. | ||
| */ | ||
| if (slot_type == SOF_IPC4_DEBUG_SLOT_DEBUG_STREAM && | ||
| sof_ipc4_find_debug_slot_offset_by_type(sdev, slot_type) == | ||
| sdev->debug_box.offset + SOF_IPC4_DEBUG_PAGE0_SLOT_OFFSET) | ||
| return; | ||
|
jsarha marked this conversation as resolved.
|
||
|
|
||
| if (data_offset >= SOF_IPC4_DEBUG_SLOT_SIZE) | ||
| return; | ||
|
|
||
| ud = devm_kzalloc(sdev->dev, sizeof(*ud), GFP_KERNEL); | ||
| if (!ud) | ||
| return; | ||
|
|
||
| ud->dfse.type = SOF_DFSENTRY_TYPE_IOMEM; | ||
| ud->dfse.size = exposed_size; | ||
| ud->dfse.access_type = SOF_DEBUGFS_ACCESS_ALWAYS; | ||
| ud->dfse.sdev = sdev; | ||
|
|
||
| ud->slot_type = slot_type; | ||
| ud->data_offset = data_offset; | ||
|
|
||
| list_add(&ud->dfse.list, &sdev->dfsentry_list); | ||
|
|
||
| debugfs_create_file(name, 0444, sdev->debugfs_root, ud, &sof_debug_stream_fops); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
| #include "ipc4-fw-reg.h" | ||
| #include "ipc4-priv.h" | ||
| #include "ipc4-topology.h" | ||
| #include "ipc4-telemetry.h" | ||
| #include "ops.h" | ||
|
|
||
| static const struct sof_ipc4_fw_status { | ||
|
|
@@ -720,7 +719,8 @@ size_t sof_ipc4_find_debug_slot_offset_by_type(struct snd_sof_dev *sdev, | |
| slot_desc_type_offset += SOF_IPC4_DEBUG_DESCRIPTOR_SIZE; | ||
| } | ||
|
|
||
| dev_dbg(sdev->dev, "Slot type %#x is not available in debug window\n", slot_type); | ||
| dev_dbg_ratelimited(sdev->dev, "Slot type %#x is not available in debug window\n", | ||
| slot_type); | ||
| return 0; | ||
| } | ||
| EXPORT_SYMBOL(sof_ipc4_find_debug_slot_offset_by_type); | ||
|
|
@@ -741,7 +741,12 @@ static int ipc4_fw_ready(struct snd_sof_dev *sdev, struct sof_ipc4_msg *ipc4_msg | |
| return 0; | ||
| } | ||
|
|
||
| sof_ipc4_create_exception_debugfs_node(sdev); | ||
| /* sizeof(u32) is for skipping the first separator magic number */ | ||
| sof_ipc4_create_debug_slot_ro_debugfs_node(sdev, SOF_IPC4_DEBUG_SLOT_TELEMETRY, | ||
| sizeof(u32), "exception"); | ||
|
|
||
| sof_ipc4_create_debug_slot_ro_debugfs_node(sdev, SOF_IPC4_DEBUG_SLOT_DEBUG_STREAM, | ||
| 0, "debug_stream"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to say "probes_stream" instead here ? |
||
|
|
||
| return sof_ipc4_init_msg_memory(sdev); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better to just allocate this on open() and then free it on close(). This way we simplify and optimize the flow.