drivers/vfio/platform/vfio_platform_irq.c
Source file repositories/reference/linux-study-clean/drivers/vfio/platform/vfio_platform_irq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vfio/platform/vfio_platform_irq.c- Extension
.c- Size
- 8379 bytes
- Lines
- 369
- Domain
- Driver Families
- Bucket
- drivers/vfio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/eventfd.hlinux/interrupt.hlinux/slab.hlinux/types.hlinux/vfio.hlinux/irq.hvfio_platform_private.h
Detected Declarations
function Copyrightfunction vfio_platform_mask_handlerfunction vfio_platform_set_irq_maskfunction vfio_platform_unmaskfunction vfio_platform_unmask_handlerfunction vfio_platform_set_irq_unmaskfunction vfio_send_eventfdfunction vfio_automasked_irq_handlerfunction vfio_irq_handlerfunction vfio_set_triggerfunction vfio_platform_set_irq_triggerfunction vfio_platform_set_irqs_ioctlfunction vfio_platform_irq_initfunction vfio_platform_irq_cleanup
Annotated Snippet
if (hwirq < 0) {
ret = -EINVAL;
goto err;
}
spin_lock_init(&vdev->irqs[i].lock);
vdev->irqs[i].flags = VFIO_IRQ_INFO_EVENTFD;
if (irq_get_trigger_type(hwirq) & IRQ_TYPE_LEVEL_MASK) {
vdev->irqs[i].flags |= VFIO_IRQ_INFO_MASKABLE
| VFIO_IRQ_INFO_AUTOMASKED;
handler = vfio_automasked_irq_handler;
}
vdev->irqs[i].count = 1;
vdev->irqs[i].hwirq = hwirq;
vdev->irqs[i].masked = false;
vdev->irqs[i].name = kasprintf(GFP_KERNEL_ACCOUNT,
"vfio-irq[%d](%s)", hwirq,
vdev->name);
if (!vdev->irqs[i].name) {
ret = -ENOMEM;
goto err;
}
ret = request_irq(hwirq, handler, IRQF_NO_AUTOEN,
vdev->irqs[i].name, &vdev->irqs[i]);
if (ret) {
kfree(vdev->irqs[i].name);
vdev->irqs[i].name = ERR_PTR(ret);
}
}
vdev->num_irqs = cnt;
return 0;
err:
for (--i; i >= 0; i--) {
if (!IS_ERR(vdev->irqs[i].name)) {
free_irq(vdev->irqs[i].hwirq, &vdev->irqs[i]);
kfree(vdev->irqs[i].name);
}
}
kfree(vdev->irqs);
return ret;
}
void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev)
{
int i;
for (i = 0; i < vdev->num_irqs; i++) {
vfio_virqfd_disable(&vdev->irqs[i].mask);
vfio_virqfd_disable(&vdev->irqs[i].unmask);
if (!IS_ERR(vdev->irqs[i].name)) {
free_irq(vdev->irqs[i].hwirq, &vdev->irqs[i]);
if (vdev->irqs[i].trigger)
eventfd_ctx_put(vdev->irqs[i].trigger);
kfree(vdev->irqs[i].name);
}
}
vdev->num_irqs = 0;
kfree(vdev->irqs);
}
Annotation
- Immediate include surface: `linux/eventfd.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/types.h`, `linux/vfio.h`, `linux/irq.h`, `vfio_platform_private.h`.
- Detected declarations: `function Copyright`, `function vfio_platform_mask_handler`, `function vfio_platform_set_irq_mask`, `function vfio_platform_unmask`, `function vfio_platform_unmask_handler`, `function vfio_platform_set_irq_unmask`, `function vfio_send_eventfd`, `function vfio_automasked_irq_handler`, `function vfio_irq_handler`, `function vfio_set_trigger`.
- Atlas domain: Driver Families / drivers/vfio.
- Implementation status: source 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.