drivers/vfio/platform/vfio_amba.c
Source file repositories/reference/linux-study-clean/drivers/vfio/platform/vfio_amba.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vfio/platform/vfio_amba.c- Extension
.c- Size
- 3823 bytes
- Lines
- 150
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hlinux/vfio.hlinux/pm_runtime.hlinux/amba/bus.hvfio_platform_private.h
Detected Declarations
function Copyrightfunction get_amba_irqfunction vfio_amba_init_devfunction vfio_amba_probefunction vfio_amba_release_devfunction vfio_amba_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2013 - Virtual Open Systems
* Author: Antonios Motakis <a.motakis@virtualopensystems.com>
*/
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/vfio.h>
#include <linux/pm_runtime.h>
#include <linux/amba/bus.h>
#include "vfio_platform_private.h"
#define DRIVER_VERSION "0.10"
#define DRIVER_AUTHOR "Antonios Motakis <a.motakis@virtualopensystems.com>"
#define DRIVER_DESC "VFIO for AMBA devices - User Level meta-driver"
/* probing devices from the AMBA bus */
static struct resource *get_amba_resource(struct vfio_platform_device *vdev,
int i)
{
struct amba_device *adev = (struct amba_device *) vdev->opaque;
if (i == 0)
return &adev->res;
return NULL;
}
static int get_amba_irq(struct vfio_platform_device *vdev, int i)
{
struct amba_device *adev = (struct amba_device *) vdev->opaque;
int ret = 0;
if (i < AMBA_NR_IRQS)
ret = adev->irq[i];
/* zero is an unset IRQ for AMBA devices */
return ret ? ret : -ENXIO;
}
static int vfio_amba_init_dev(struct vfio_device *core_vdev)
{
struct vfio_platform_device *vdev =
container_of(core_vdev, struct vfio_platform_device, vdev);
struct amba_device *adev = to_amba_device(core_vdev->dev);
int ret;
vdev->name = kasprintf(GFP_KERNEL, "vfio-amba-%08x", adev->periphid);
if (!vdev->name)
return -ENOMEM;
vdev->opaque = (void *) adev;
vdev->flags = VFIO_DEVICE_FLAGS_AMBA;
vdev->get_resource = get_amba_resource;
vdev->get_irq = get_amba_irq;
vdev->reset_required = false;
ret = vfio_platform_init_common(vdev);
if (ret)
kfree(vdev->name);
return ret;
}
static const struct vfio_device_ops vfio_amba_ops;
static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id)
{
struct vfio_platform_device *vdev;
int ret;
dev_err_once(&adev->dev, "DEPRECATION: vfio-amba is deprecated and will be removed in a future kernel release\n");
vdev = vfio_alloc_device(vfio_platform_device, vdev, &adev->dev,
&vfio_amba_ops);
if (IS_ERR(vdev))
return PTR_ERR(vdev);
ret = vfio_register_group_dev(&vdev->vdev);
if (ret)
goto out_put_vdev;
pm_runtime_enable(&adev->dev);
dev_set_drvdata(&adev->dev, vdev);
return 0;
out_put_vdev:
vfio_put_device(&vdev->vdev);
return ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/vfio.h`, `linux/pm_runtime.h`, `linux/amba/bus.h`, `vfio_platform_private.h`.
- Detected declarations: `function Copyright`, `function get_amba_irq`, `function vfio_amba_init_dev`, `function vfio_amba_probe`, `function vfio_amba_release_dev`, `function vfio_amba_remove`.
- Atlas domain: Driver Families / drivers/vfio.
- Implementation status: source 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.