drivers/accel/qaic/qaic_drv.c
Source file repositories/reference/linux-study-clean/drivers/accel/qaic/qaic_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/qaic/qaic_drv.c- Extension
.c- Size
- 22512 bytes
- Lines
- 859
- Domain
- Driver Families
- Bucket
- drivers/accel
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/dma-mapping.hlinux/idr.hlinux/interrupt.hlinux/list.hlinux/kobject.hlinux/kref.hlinux/mhi.hlinux/module.hlinux/msi.hlinux/mutex.hlinux/pci.hlinux/spinlock.hlinux/workqueue.hlinux/wait.hdrm/drm_accel.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_gem.hdrm/drm_ioctl.hdrm/drm_managed.huapi/drm/qaic_accel.hmhi_controller.hqaic.hqaic_debugfs.hqaic_ras.hqaic_ssr.hqaic_timesync.hsahara.h
Detected Declarations
struct qaic_device_configfunction qaicm_wq_releasefunction qaicm_srcu_releasefunction qaicm_srcu_initfunction qaicm_pci_releasefunction free_usrfunction qaic_openfunction qaic_postclosefunction qaic_create_drm_devicefunction qaic_destroy_drm_devicefunction qaic_mhi_probefunction qaic_mhi_removefunction qaic_dev_reset_clean_local_statefunction init_pcifunction init_msifunction qaic_pci_probefunction qaic_pci_removefunction qaic_pci_shutdownfunction qaic_pci_error_detectedfunction qaic_pci_reset_preparefunction qaic_pci_reset_donefunction qaic_is_under_resetfunction qaic_data_path_busyfunction qaic_pm_suspendfunction qaic_pm_resumefunction qaic_initfunction qaic_exitmodule init qaic_init
Annotated Snippet
static struct pci_driver qaic_pci_driver = {
.name = QAIC_NAME,
.id_table = qaic_ids,
.probe = qaic_pci_probe,
.remove = qaic_pci_remove,
.shutdown = qaic_pci_shutdown,
.err_handler = &qaic_pci_err_handler,
.driver = {
.pm = pm_sleep_ptr(&qaic_pm_ops),
},
};
static int __init qaic_init(void)
{
int ret;
ret = pci_register_driver(&qaic_pci_driver);
if (ret) {
pr_debug("qaic: pci_register_driver failed %d\n", ret);
return ret;
}
ret = mhi_driver_register(&qaic_mhi_driver);
if (ret) {
pr_debug("qaic: mhi_driver_register failed %d\n", ret);
goto free_pci;
}
ret = sahara_register();
if (ret) {
pr_debug("qaic: sahara_register failed %d\n", ret);
goto free_mhi;
}
ret = qaic_timesync_init();
if (ret)
pr_debug("qaic: qaic_timesync_init failed %d\n", ret);
ret = qaic_bootlog_register();
if (ret)
pr_debug("qaic: qaic_bootlog_register failed %d\n", ret);
ret = qaic_ras_register();
if (ret)
pr_debug("qaic: qaic_ras_register failed %d\n", ret);
ret = qaic_ssr_register();
if (ret) {
pr_debug("qaic: qaic_ssr_register failed %d\n", ret);
goto free_bootlog;
}
return 0;
free_bootlog:
qaic_bootlog_unregister();
free_mhi:
mhi_driver_unregister(&qaic_mhi_driver);
free_pci:
pci_unregister_driver(&qaic_pci_driver);
return ret;
}
static void __exit qaic_exit(void)
{
/*
* We assume that qaic_pci_remove() is called due to a hotplug event
* which would mean that the link is down, and thus
* qaic_mhi_free_controller() should not try to access the device during
* cleanup.
* We call pci_unregister_driver() below, which also triggers
* qaic_pci_remove(), but since this is module exit, we expect the link
* to the device to be up, in which case qaic_mhi_free_controller()
* should try to access the device during cleanup to put the device in
* a sane state.
* For that reason, we set link_up here to let qaic_mhi_free_controller
* know the expected link state. Since the module is going to be
* removed at the end of this, we don't need to worry about
* reinitializing the link_up state after the cleanup is done.
*/
link_up = true;
qaic_ssr_unregister();
qaic_ras_unregister();
qaic_bootlog_unregister();
qaic_timesync_deinit();
sahara_unregister();
mhi_driver_unregister(&qaic_mhi_driver);
pci_unregister_driver(&qaic_pci_driver);
}
module_init(qaic_init);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/idr.h`, `linux/interrupt.h`, `linux/list.h`, `linux/kobject.h`, `linux/kref.h`, `linux/mhi.h`.
- Detected declarations: `struct qaic_device_config`, `function qaicm_wq_release`, `function qaicm_srcu_release`, `function qaicm_srcu_init`, `function qaicm_pci_release`, `function free_usr`, `function qaic_open`, `function qaic_postclose`, `function qaic_create_drm_device`, `function qaic_destroy_drm_device`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.