drivers/accel/ivpu/ivpu_drv.c
Source file repositories/reference/linux-study-clean/drivers/accel/ivpu/ivpu_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/ivpu/ivpu_drv.c- Extension
.c- Size
- 23534 bytes
- Lines
- 894
- 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/firmware.hlinux/module.hlinux/pci.hlinux/pm_runtime.hlinux/workqueue.hgenerated/utsrelease.hdrm/drm_accel.hdrm/drm_file.hdrm/drm_gem.hdrm/drm_ioctl.hdrm/drm_prime.hivpu_coredump.hivpu_debugfs.hivpu_drv.hivpu_fw.hivpu_fw_log.hivpu_gem.hivpu_hw.hivpu_ipc.hivpu_job.hivpu_jsm_msg.hivpu_mmu.hivpu_mmu_context.hivpu_ms.hivpu_pm.hivpu_sysfs.hvpu_boot_api.h
Detected Declarations
function hash_for_each_possiblefunction ivpu_user_limits_releasefunction ivpu_user_limits_putfunction file_priv_unbindfunction file_priv_releasefunction ivpu_file_priv_putfunction ivpu_is_capablefunction ivpu_get_param_ioctlfunction ivpu_set_param_ioctlfunction ivpu_openfunction ivpu_postclosefunction ivpu_wait_for_readyfunction ivpu_hw_sched_initfunction ivpu_bootfunction ivpu_prepare_for_resetfunction ivpu_shutdownfunction ivpu_gem_prime_handle_to_fdfunction ivpu_irq_initfunction ivpu_pci_initfunction ivpu_dev_initfunction ivpu_bo_unbind_all_user_contextsfunction ivpu_dev_finifunction ivpu_probefunction ivpu_remove
Annotated Snippet
static const struct file_operations ivpu_fops = {
.owner = THIS_MODULE,
DRM_ACCEL_FOPS,
#ifdef CONFIG_PROC_FS
.show_fdinfo = drm_show_fdinfo,
#endif
};
static int ivpu_gem_prime_handle_to_fd(struct drm_device *dev, struct drm_file *file_priv,
u32 handle, u32 flags, int *prime_fd)
{
struct drm_gem_object *obj;
obj = drm_gem_object_lookup(file_priv, handle);
if (!obj)
return -ENOENT;
if (drm_gem_is_imported(obj)) {
/* Do not allow re-exporting */
drm_gem_object_put(obj);
return -EOPNOTSUPP;
}
drm_gem_object_put(obj);
return drm_gem_prime_handle_to_fd(dev, file_priv, handle, flags, prime_fd);
}
static const struct drm_driver driver = {
.driver_features = DRIVER_GEM | DRIVER_COMPUTE_ACCEL,
.open = ivpu_open,
.postclose = ivpu_postclose,
.gem_create_object = ivpu_gem_create_object,
.gem_prime_import = ivpu_gem_prime_import,
.prime_handle_to_fd = ivpu_gem_prime_handle_to_fd,
.ioctls = ivpu_drm_ioctls,
.num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
.fops = &ivpu_fops,
#ifdef CONFIG_PROC_FS
.show_fdinfo = drm_show_memory_stats,
#endif
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.major = 1,
};
static int ivpu_irq_init(struct ivpu_device *vdev)
{
struct pci_dev *pdev = to_pci_dev(vdev->drm.dev);
int ret;
ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (ret < 0) {
ivpu_err(vdev, "Failed to allocate a MSI IRQ: %d\n", ret);
return ret;
}
INIT_WORK(&vdev->irq_ipc_work, ivpu_ipc_irq_work_fn);
INIT_WORK(&vdev->irq_dct_work, ivpu_pm_irq_dct_work_fn);
INIT_WORK(&vdev->context_abort_work, ivpu_context_abort_work_fn);
ivpu_irq_handlers_init(vdev);
vdev->irq = pci_irq_vector(pdev, 0);
ret = devm_request_irq(vdev->drm.dev, vdev->irq, ivpu_hw_irq_handler,
IRQF_NO_AUTOEN, DRIVER_NAME, vdev);
if (ret)
ivpu_err(vdev, "Failed to request an IRQ %d\n", ret);
return ret;
}
static int ivpu_pci_init(struct ivpu_device *vdev)
{
struct pci_dev *pdev = to_pci_dev(vdev->drm.dev);
struct resource *bar0 = &pdev->resource[0];
struct resource *bar4 = &pdev->resource[4];
int ret;
ivpu_dbg(vdev, MISC, "Mapping BAR0 (RegV) %pR\n", bar0);
vdev->regv = devm_ioremap_resource(vdev->drm.dev, bar0);
if (IS_ERR(vdev->regv)) {
ivpu_err(vdev, "Failed to map bar 0: %pe\n", vdev->regv);
return PTR_ERR(vdev->regv);
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/pci.h`, `linux/pm_runtime.h`, `linux/workqueue.h`, `generated/utsrelease.h`, `drm/drm_accel.h`, `drm/drm_file.h`.
- Detected declarations: `function hash_for_each_possible`, `function ivpu_user_limits_release`, `function ivpu_user_limits_put`, `function file_priv_unbind`, `function file_priv_release`, `function ivpu_file_priv_put`, `function ivpu_is_capable`, `function ivpu_get_param_ioctl`, `function ivpu_set_param_ioctl`, `function ivpu_open`.
- 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.