drivers/vfio/platform/vfio_platform_common.c
Source file repositories/reference/linux-study-clean/drivers/vfio/platform/vfio_platform_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vfio/platform/vfio_platform_common.c- Extension
.c- Size
- 16780 bytes
- Lines
- 702
- Domain
- Driver Families
- Bucket
- drivers/vfio
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/device.hlinux/acpi.hlinux/iommu.hlinux/module.hlinux/mutex.hlinux/pm_runtime.hlinux/slab.hlinux/types.hlinux/uaccess.hlinux/vfio.hvfio_platform_private.h
Detected Declarations
function vfio_platform_lookup_resetfunction vfio_platform_acpi_probefunction vfio_platform_acpi_call_resetfunction vfio_platform_acpi_has_resetfunction vfio_platform_has_resetfunction vfio_platform_get_resetfunction vfio_platform_put_resetfunction vfio_platform_regions_initfunction vfio_platform_regions_cleanupfunction vfio_platform_call_resetfunction vfio_platform_close_devicefunction vfio_platform_open_devicefunction vfio_platform_ioctl_get_region_infofunction vfio_platform_ioctlfunction vfio_platform_read_mmiofunction vfio_platform_readfunction vfio_platform_write_mmiofunction vfio_platform_writefunction vfio_platform_mmap_mmiofunction vfio_platform_mmapfunction vfio_platform_of_probefunction vfio_platform_init_commonfunction vfio_platform_release_commonfunction __vfio_platform_register_resetfunction vfio_platform_unregister_resetexport vfio_platform_close_deviceexport vfio_platform_open_deviceexport vfio_platform_ioctl_get_region_infoexport vfio_platform_ioctlexport vfio_platform_readexport vfio_platform_writeexport vfio_platform_mmapexport vfio_platform_init_commonexport vfio_platform_release_commonexport __vfio_platform_register_resetexport vfio_platform_unregister_reset
Annotated Snippet
try_module_get(iter->owner)) {
*module = iter->owner;
reset_fn = iter->of_reset;
break;
}
}
mutex_unlock(&driver_lock);
return reset_fn;
}
static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev,
struct device *dev)
{
struct acpi_device *adev;
if (acpi_disabled)
return -ENOENT;
adev = ACPI_COMPANION(dev);
if (!adev) {
dev_err(dev, "ACPI companion device not found for %s\n",
vdev->name);
return -ENODEV;
}
#ifdef CONFIG_ACPI
vdev->acpihid = acpi_device_hid(adev);
#endif
return WARN_ON(!vdev->acpihid) ? -EINVAL : 0;
}
static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev,
const char **extra_dbg)
{
#ifdef CONFIG_ACPI
struct device *dev = vdev->device;
acpi_handle handle = ACPI_HANDLE(dev);
acpi_status acpi_ret;
acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL);
if (ACPI_FAILURE(acpi_ret)) {
if (extra_dbg)
*extra_dbg = acpi_format_exception(acpi_ret);
return -EINVAL;
}
return 0;
#else
return -ENOENT;
#endif
}
static bool vfio_platform_acpi_has_reset(struct vfio_platform_device *vdev)
{
#ifdef CONFIG_ACPI
struct device *dev = vdev->device;
acpi_handle handle = ACPI_HANDLE(dev);
return acpi_has_method(handle, "_RST");
#else
return false;
#endif
}
static bool vfio_platform_has_reset(struct vfio_platform_device *vdev)
{
if (VFIO_PLATFORM_IS_ACPI(vdev))
return vfio_platform_acpi_has_reset(vdev);
return vdev->of_reset ? true : false;
}
static int vfio_platform_get_reset(struct vfio_platform_device *vdev)
{
if (VFIO_PLATFORM_IS_ACPI(vdev))
return vfio_platform_acpi_has_reset(vdev) ? 0 : -ENOENT;
vdev->of_reset = vfio_platform_lookup_reset(vdev->compat,
&vdev->reset_module);
if (!vdev->of_reset) {
request_module("vfio-reset:%s", vdev->compat);
vdev->of_reset = vfio_platform_lookup_reset(vdev->compat,
&vdev->reset_module);
}
return vdev->of_reset ? 0 : -ENOENT;
}
static void vfio_platform_put_reset(struct vfio_platform_device *vdev)
{
Annotation
- Immediate include surface: `linux/device.h`, `linux/acpi.h`, `linux/iommu.h`, `linux/module.h`, `linux/mutex.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/types.h`.
- Detected declarations: `function vfio_platform_lookup_reset`, `function vfio_platform_acpi_probe`, `function vfio_platform_acpi_call_reset`, `function vfio_platform_acpi_has_reset`, `function vfio_platform_has_reset`, `function vfio_platform_get_reset`, `function vfio_platform_put_reset`, `function vfio_platform_regions_init`, `function vfio_platform_regions_cleanup`, `function vfio_platform_call_reset`.
- Atlas domain: Driver Families / drivers/vfio.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.