sound/soc/sof/loader.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/loader.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/loader.c- Extension
.c- Size
- 4939 bytes
- Lines
- 191
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hsof-priv.hops.h
Detected Declarations
function snd_sof_load_firmware_rawfunction snd_sof_load_firmware_memcpyfunction snd_sof_run_firmwarefunction snd_sof_fw_unloadexport snd_sof_load_firmware_rawexport snd_sof_load_firmware_memcpyexport snd_sof_run_firmwareexport snd_sof_fw_unload
Annotated Snippet
if (ret < 0) {
dev_err(sdev->dev, "Firmware loading failed\n");
goto error;
}
}
return 0;
error:
release_firmware(sdev->basefw.fw);
sdev->basefw.fw = NULL;
return ret;
}
EXPORT_SYMBOL(snd_sof_load_firmware_memcpy);
int snd_sof_run_firmware(struct snd_sof_dev *sdev)
{
int ret;
init_waitqueue_head(&sdev->boot_wait);
/* (re-)enable dsp dump */
sdev->dbg_dump_printed = false;
sdev->ipc_dump_printed = false;
/* create read-only fw_version debugfs to store boot version info */
if (sdev->first_boot) {
ret = snd_sof_debugfs_buf_item(sdev, &sdev->fw_version,
sizeof(sdev->fw_version),
"fw_version", 0444);
/* errors are only due to memory allocation, not debugfs */
if (ret < 0) {
dev_err(sdev->dev, "snd_sof_debugfs_buf_item failed\n");
return ret;
}
}
/* perform pre fw run operations */
ret = snd_sof_dsp_pre_fw_run(sdev);
if (ret < 0) {
dev_err(sdev->dev, "failed pre fw run op\n");
return ret;
}
dev_dbg(sdev->dev, "booting DSP firmware\n");
/* boot the firmware on the DSP */
ret = snd_sof_dsp_run(sdev);
if (ret < 0) {
snd_sof_dsp_dbg_dump(sdev, "Failed to start DSP",
SOF_DBG_DUMP_MBOX | SOF_DBG_DUMP_PCI);
return ret;
}
/*
* now wait for the DSP to boot. There are 3 possible outcomes:
* 1. Boot wait times out indicating FW boot failure.
* 2. FW boots successfully and fw_ready op succeeds.
* 3. FW boots but fw_ready op fails.
*/
ret = wait_event_timeout(sdev->boot_wait,
sdev->fw_state > SOF_FW_BOOT_IN_PROGRESS,
msecs_to_jiffies(sdev->boot_timeout));
if (ret == 0) {
snd_sof_dsp_dbg_dump(sdev, "Firmware boot failure due to timeout",
SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX |
SOF_DBG_DUMP_TEXT | SOF_DBG_DUMP_PCI);
return -EIO;
}
if (sdev->fw_state == SOF_FW_BOOT_READY_FAILED)
return -EIO; /* FW boots but fw_ready op failed */
dev_dbg(sdev->dev, "firmware boot complete\n");
sof_set_fw_state(sdev, SOF_FW_BOOT_COMPLETE);
/* perform post fw run operations */
ret = snd_sof_dsp_post_fw_run(sdev);
if (ret < 0) {
dev_err(sdev->dev, "error: failed post fw run op\n");
return ret;
}
if (sdev->ipc->ops->post_fw_boot)
return sdev->ipc->ops->post_fw_boot(sdev);
return 0;
}
EXPORT_SYMBOL(snd_sof_run_firmware);
Annotation
- Immediate include surface: `linux/firmware.h`, `sof-priv.h`, `ops.h`.
- Detected declarations: `function snd_sof_load_firmware_raw`, `function snd_sof_load_firmware_memcpy`, `function snd_sof_run_firmware`, `function snd_sof_fw_unload`, `export snd_sof_load_firmware_raw`, `export snd_sof_load_firmware_memcpy`, `export snd_sof_run_firmware`, `export snd_sof_fw_unload`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
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.