sound/soc/sof/ipc4-mtrace.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/ipc4-mtrace.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/ipc4-mtrace.c- Extension
.c- Size
- 18147 bytes
- Lines
- 667
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/sched/signal.hlinux/sched/clock.hsound/sof/ipc4/header.hsof-priv.hipc4-priv.h
Detected Declarations
struct sof_log_state_infostruct sof_mtrace_core_datastruct sof_mtrace_privenum sof_mtrace_statefunction sof_ipc4_mtrace_dfs_openfunction sof_wait_mtrace_availfunction sof_ipc4_mtrace_dfs_readfunction sof_ipc4_mtrace_dfs_releasefunction scoped_guardfunction sof_ipc4_priority_mask_dfs_readfunction sof_ipc4_priority_mask_dfs_writefunction mtrace_debugfs_createfunction ipc4_mtrace_enablefunction ipc4_mtrace_disablefunction checkfunction ipc4_mtrace_initfunction ipc4_mtrace_freefunction sof_ipc4_mtrace_update_pos_all_coresfunction sof_ipc4_mtrace_update_posfunction ipc4_mtrace_fw_crashedfunction ipc4_mtrace_resumefunction ipc4_mtrace_suspend
Annotated Snippet
static const struct file_operations sof_dfs_mtrace_fops = {
.open = sof_ipc4_mtrace_dfs_open,
.read = sof_ipc4_mtrace_dfs_read,
.llseek = default_llseek,
.release = sof_ipc4_mtrace_dfs_release,
.owner = THIS_MODULE,
};
static ssize_t sof_ipc4_priority_mask_dfs_read(struct file *file, char __user *to,
size_t count, loff_t *ppos)
{
struct sof_mtrace_priv *priv = file->private_data;
int i, ret, offset, remaining;
char *buf;
/*
* one entry (14 char + new line = 15):
* " 0: 000001ef"
*
* 16 * 15 + 1 = 241
*/
buf = kzalloc(241, GFP_KERNEL);
if (!buf)
return -ENOMEM;
for (i = 0; i < MAX_ALLOWED_LIBRARIES; i++) {
offset = strlen(buf);
remaining = 241 - offset;
snprintf(buf + offset, remaining, "%2d: 0x%08x\n", i,
priv->state_info.logs_priorities_mask[i]);
}
ret = simple_read_from_buffer(to, count, ppos, buf, strlen(buf));
kfree(buf);
return ret;
}
static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
const char __user *from,
size_t count, loff_t *ppos)
{
struct sof_mtrace_priv *priv = file->private_data;
unsigned int id;
char *buf;
u32 mask;
int ret;
/*
* To update Nth mask entry, write:
* "N,0x1234" or "N,1234" to the debugfs file
* The mask will be interpreted as hexadecimal number
*/
buf = memdup_user_nul(from, count);
if (IS_ERR(buf))
return PTR_ERR(buf);
ret = sscanf(buf, "%u,0x%x", &id, &mask);
if (ret != 2) {
ret = sscanf(buf, "%u,%x", &id, &mask);
if (ret != 2) {
ret = -EINVAL;
goto out;
}
}
if (id >= MAX_ALLOWED_LIBRARIES) {
ret = -EINVAL;
goto out;
}
priv->state_info.logs_priorities_mask[id] = mask;
ret = count;
out:
kfree(buf);
return ret;
}
static const struct file_operations sof_dfs_priority_mask_fops = {
.open = simple_open,
.read = sof_ipc4_priority_mask_dfs_read,
.write = sof_ipc4_priority_mask_dfs_write,
.llseek = default_llseek,
.owner = THIS_MODULE,
};
static int mtrace_debugfs_create(struct snd_sof_dev *sdev)
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/sched/signal.h`, `linux/sched/clock.h`, `sound/sof/ipc4/header.h`, `sof-priv.h`, `ipc4-priv.h`.
- Detected declarations: `struct sof_log_state_info`, `struct sof_mtrace_core_data`, `struct sof_mtrace_priv`, `enum sof_mtrace_state`, `function sof_ipc4_mtrace_dfs_open`, `function sof_wait_mtrace_avail`, `function sof_ipc4_mtrace_dfs_read`, `function sof_ipc4_mtrace_dfs_release`, `function scoped_guard`, `function sof_ipc4_priority_mask_dfs_read`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.