sound/soc/sof/sof-client-ipc-flood-test.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/sof-client-ipc-flood-test.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/sof-client-ipc-flood-test.c- Extension
.c- Size
- 10536 bytes
- Lines
- 385
- 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/auxiliary_bus.hlinux/completion.hlinux/debugfs.hlinux/ktime.hlinux/mod_devicetable.hlinux/module.hlinux/pm_runtime.hlinux/slab.hlinux/uaccess.hsound/sof/header.hsof-client.h
Detected Declarations
struct sof_ipc_flood_privfunction sof_ipc_flood_dfs_openfunction sof_debug_ipc_flood_testfunction sof_ipc_flood_dfs_writefunction sof_ipc_flood_dfs_readfunction sof_ipc_flood_dfs_releasefunction sof_ipc_flood_probefunction sof_ipc_flood_remove
Annotated Snippet
static const struct file_operations sof_ipc_flood_fops = {
.open = sof_ipc_flood_dfs_open,
.read = sof_ipc_flood_dfs_read,
.llseek = default_llseek,
.write = sof_ipc_flood_dfs_write,
.release = sof_ipc_flood_dfs_release,
.owner = THIS_MODULE,
};
/*
* The IPC test client creates a couple of debugfs entries that will be used
* flood tests. Users can write to these entries to execute the IPC flood test
* by specifying either the number of IPCs to flood the DSP with or the duration
* (in ms) for which the DSP should be flooded with test IPCs. At the
* end of each test, the average, min and max response times are reported back.
* The results of the last flood test can be accessed by reading the debugfs
* entries.
*/
static int sof_ipc_flood_probe(struct auxiliary_device *auxdev,
const struct auxiliary_device_id *id)
{
struct sof_client_dev *cdev = auxiliary_dev_to_sof_client_dev(auxdev);
struct dentry *debugfs_root = sof_client_get_debugfs_root(cdev);
struct device *dev = &auxdev->dev;
struct sof_ipc_flood_priv *priv;
/* allocate memory for client data */
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->buf = devm_kmalloc(dev, IPC_FLOOD_TEST_RESULT_LEN, GFP_KERNEL);
if (!priv->buf)
return -ENOMEM;
cdev->data = priv;
/* create debugfs root folder with device name under parent SOF dir */
priv->dfs_root = debugfs_create_dir(dev_name(dev), debugfs_root);
if (!IS_ERR_OR_NULL(priv->dfs_root)) {
/* create read-write ipc_flood_count debugfs entry */
debugfs_create_file_aux_num(DEBUGFS_IPC_FLOOD_COUNT, 0644,
priv->dfs_root, cdev, 0, &sof_ipc_flood_fops);
/* create read-write ipc_flood_duration_ms debugfs entry */
debugfs_create_file_aux_num(DEBUGFS_IPC_FLOOD_DURATION, 0644,
priv->dfs_root, cdev, 1, &sof_ipc_flood_fops);
if (auxdev->id == 0) {
/*
* Create symlinks for backwards compatibility to the
* first IPC flood test instance
*/
char target[100];
snprintf(target, 100, "%s/" DEBUGFS_IPC_FLOOD_COUNT,
dev_name(dev));
priv->dfs_link[0] =
debugfs_create_symlink(DEBUGFS_IPC_FLOOD_COUNT,
debugfs_root, target);
snprintf(target, 100, "%s/" DEBUGFS_IPC_FLOOD_DURATION,
dev_name(dev));
priv->dfs_link[1] =
debugfs_create_symlink(DEBUGFS_IPC_FLOOD_DURATION,
debugfs_root, target);
}
}
/* enable runtime PM */
pm_runtime_set_autosuspend_delay(dev, SOF_IPC_CLIENT_SUSPEND_DELAY_MS);
pm_runtime_use_autosuspend(dev);
pm_runtime_enable(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_idle(dev);
return 0;
}
static void sof_ipc_flood_remove(struct auxiliary_device *auxdev)
{
struct sof_client_dev *cdev = auxiliary_dev_to_sof_client_dev(auxdev);
struct sof_ipc_flood_priv *priv = cdev->data;
pm_runtime_disable(&auxdev->dev);
if (auxdev->id == 0) {
debugfs_remove(priv->dfs_link[0]);
debugfs_remove(priv->dfs_link[1]);
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/completion.h`, `linux/debugfs.h`, `linux/ktime.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/slab.h`.
- Detected declarations: `struct sof_ipc_flood_priv`, `function sof_ipc_flood_dfs_open`, `function sof_debug_ipc_flood_test`, `function sof_ipc_flood_dfs_write`, `function sof_ipc_flood_dfs_read`, `function sof_ipc_flood_dfs_release`, `function sof_ipc_flood_probe`, `function sof_ipc_flood_remove`.
- 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.