sound/soc/sof/debug.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/debug.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/debug.c- Extension
.c- Size
- 13132 bytes
- Lines
- 475
- 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/io.hlinux/pm_runtime.hsound/sof/ext_manifest.hsound/sof/debug.hsof-priv.hops.h
Detected Declarations
function sof_dfsentry_readfunction snd_sof_debugfs_io_itemfunction snd_sof_debugfs_add_region_item_iomemfunction snd_sof_debugfs_buf_itemfunction memory_info_updatefunction memory_info_readfunction memory_info_openfunction snd_sof_dbg_memory_info_initfunction snd_sof_dbg_initfunction snd_sof_free_debugfunction snd_sof_dbg_print_fw_statefunction snd_sof_dsp_dbg_dumpfunction snd_sof_ipc_dumpfunction snd_sof_handle_fw_exceptionexport snd_sof_debugfs_add_region_item_iomemexport snd_sof_debugfs_buf_itemexport snd_sof_dbg_memory_info_initexport snd_sof_dbg_initexport snd_sof_free_debugexport snd_sof_dsp_dbg_dumpexport snd_sof_handle_fw_exception
Annotated Snippet
static const struct file_operations sof_dfs_fops = {
.open = simple_open,
.read = sof_dfsentry_read,
.llseek = default_llseek,
};
/* create FS entry for debug files that can expose DSP memories, registers */
static int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev,
void __iomem *base, size_t size,
const char *name,
enum sof_debugfs_access_type access_type)
{
struct snd_sof_dfsentry *dfse;
if (!sdev)
return -EINVAL;
dfse = devm_kzalloc(sdev->dev, sizeof(*dfse), GFP_KERNEL);
if (!dfse)
return -ENOMEM;
dfse->type = SOF_DFSENTRY_TYPE_IOMEM;
dfse->io_mem = base;
dfse->size = size;
dfse->sdev = sdev;
dfse->access_type = access_type;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
/*
* allocate cache buffer that will be used to save the mem window
* contents prior to suspend
*/
if (access_type == SOF_DEBUGFS_ACCESS_D0_ONLY) {
dfse->cache_buf = devm_kzalloc(sdev->dev, size, GFP_KERNEL);
if (!dfse->cache_buf)
return -ENOMEM;
}
#endif
debugfs_create_file(name, 0444, sdev->debugfs_root, dfse,
&sof_dfs_fops);
/* add to dfsentry list */
list_add(&dfse->list, &sdev->dfsentry_list);
return 0;
}
int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
enum snd_sof_fw_blk_type blk_type, u32 offset,
size_t size, const char *name,
enum sof_debugfs_access_type access_type)
{
int bar = snd_sof_dsp_get_bar_index(sdev, blk_type);
if (bar < 0)
return bar;
return snd_sof_debugfs_io_item(sdev, sdev->bar[bar] + offset, size, name,
access_type);
}
EXPORT_SYMBOL_GPL(snd_sof_debugfs_add_region_item_iomem);
/* create FS entry for debug files to expose kernel memory */
int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
void *base, size_t size,
const char *name, mode_t mode)
{
struct snd_sof_dfsentry *dfse;
if (!sdev)
return -EINVAL;
dfse = devm_kzalloc(sdev->dev, sizeof(*dfse), GFP_KERNEL);
if (!dfse)
return -ENOMEM;
dfse->type = SOF_DFSENTRY_TYPE_BUF;
dfse->buf = base;
dfse->size = size;
dfse->sdev = sdev;
debugfs_create_file(name, mode, sdev->debugfs_root, dfse,
&sof_dfs_fops);
/* add to dfsentry list */
list_add(&dfse->list, &sdev->dfsentry_list);
return 0;
}
EXPORT_SYMBOL_GPL(snd_sof_debugfs_buf_item);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/io.h`, `linux/pm_runtime.h`, `sound/sof/ext_manifest.h`, `sound/sof/debug.h`, `sof-priv.h`, `ops.h`.
- Detected declarations: `function sof_dfsentry_read`, `function snd_sof_debugfs_io_item`, `function snd_sof_debugfs_add_region_item_iomem`, `function snd_sof_debugfs_buf_item`, `function memory_info_update`, `function memory_info_read`, `function memory_info_open`, `function snd_sof_dbg_memory_info_init`, `function snd_sof_dbg_init`, `function snd_sof_free_debug`.
- 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.