drivers/xen/pci.c
Source file repositories/reference/linux-study-clean/drivers/xen/pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/pci.c- Extension
.c- Size
- 8526 bytes
- Lines
- 374
- Domain
- Driver Families
- Bucket
- drivers/xen
- 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.
- 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/pci.hlinux/acpi.hlinux/pci-acpi.hxen/pci.hxen/xen.hxen/interface/physdev.hxen/interface/xen.hasm/xen/hypervisor.hasm/xen/hypercall.h../pci/pci.hasm/pci_x86.h
Detected Declarations
struct xen_device_domain_ownerfunction xen_add_devicefunction xen_remove_devicefunction xen_reset_devicefunction xen_pci_notifierfunction register_xen_pci_notifierfunction xen_mcfg_latefunction list_for_each_entryfunction xen_find_device_domain_ownerfunction xen_register_device_domain_ownerfunction xen_unregister_device_domain_ownerexport xen_reset_deviceexport xen_find_device_domain_ownerexport xen_register_device_domain_ownerexport xen_unregister_device_domain_owner
Annotated Snippet
struct xen_device_domain_owner {
domid_t domain;
struct pci_dev *dev;
struct list_head list;
};
static DEFINE_SPINLOCK(dev_domain_list_spinlock);
static LIST_HEAD(dev_domain_list);
static struct xen_device_domain_owner *find_device(struct pci_dev *dev)
{
struct xen_device_domain_owner *owner;
list_for_each_entry(owner, &dev_domain_list, list) {
if (owner->dev == dev)
return owner;
}
return NULL;
}
int xen_find_device_domain_owner(struct pci_dev *dev)
{
struct xen_device_domain_owner *owner;
int domain = -ENODEV;
spin_lock(&dev_domain_list_spinlock);
owner = find_device(dev);
if (owner)
domain = owner->domain;
spin_unlock(&dev_domain_list_spinlock);
return domain;
}
EXPORT_SYMBOL_GPL(xen_find_device_domain_owner);
int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain)
{
struct xen_device_domain_owner *owner;
owner = kzalloc_obj(struct xen_device_domain_owner);
if (!owner)
return -ENODEV;
spin_lock(&dev_domain_list_spinlock);
if (find_device(dev)) {
spin_unlock(&dev_domain_list_spinlock);
kfree(owner);
return -EEXIST;
}
owner->domain = domain;
owner->dev = dev;
list_add_tail(&owner->list, &dev_domain_list);
spin_unlock(&dev_domain_list_spinlock);
return 0;
}
EXPORT_SYMBOL_GPL(xen_register_device_domain_owner);
int xen_unregister_device_domain_owner(struct pci_dev *dev)
{
struct xen_device_domain_owner *owner;
spin_lock(&dev_domain_list_spinlock);
owner = find_device(dev);
if (!owner) {
spin_unlock(&dev_domain_list_spinlock);
return -ENODEV;
}
list_del(&owner->list);
spin_unlock(&dev_domain_list_spinlock);
kfree(owner);
return 0;
}
EXPORT_SYMBOL_GPL(xen_unregister_device_domain_owner);
#endif
Annotation
- Immediate include surface: `linux/pci.h`, `linux/acpi.h`, `linux/pci-acpi.h`, `xen/pci.h`, `xen/xen.h`, `xen/interface/physdev.h`, `xen/interface/xen.h`, `asm/xen/hypervisor.h`.
- Detected declarations: `struct xen_device_domain_owner`, `function xen_add_device`, `function xen_remove_device`, `function xen_reset_device`, `function xen_pci_notifier`, `function register_xen_pci_notifier`, `function xen_mcfg_late`, `function list_for_each_entry`, `function xen_find_device_domain_owner`, `function xen_register_device_domain_owner`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: integration 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.