drivers/iommu/iommu.c
Source file repositories/reference/linux-study-clean/drivers/iommu/iommu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/iommu.c- Extension
.c- Size
- 116312 bytes
- Lines
- 4266
- Domain
- Driver Families
- Bucket
- drivers/iommu
- 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/amba/bus.hlinux/device.hlinux/kernel.hlinux/bits.hlinux/bug.hlinux/types.hlinux/init.hlinux/export.hlinux/slab.hlinux/errno.hlinux/host1x_context_bus.hlinux/iommu.hlinux/iommufd.hlinux/idr.hlinux/err.hlinux/pci.hlinux/pci-ats.hlinux/bitops.hlinux/platform_device.hlinux/property.hlinux/fsl/mc.hlinux/module.hlinux/cc_platform.hlinux/cdx/cdx_bus.htrace/events/iommu.hlinux/sched/mm.hlinux/msi.huapi/linux/iommufd.hlinux/generic_pt/iommu.hdma-iommu.hiommu-priv.h
Detected Declarations
struct iommu_groupstruct group_devicestruct iommu_group_attributestruct group_for_pci_datafunction for_each_group_devicefunction __iommu_group_set_domainfunction __iommu_group_set_domain_nofailfunction iommu_subsys_initfunction remove_iommu_groupfunction iommu_device_registerfunction iommu_device_unregisterfunction iommu_device_unregister_busfunction iommu_device_register_busfunction iommu_mock_device_addfunction dev_iommu_freefunction device_iommu_mappedfunction dev_iommu_get_max_pasidsfunction dev_iommu_priv_setfunction iommu_init_devicefunction iommu_deinit_devicefunction release_devicefunction module_putfunction __iommu_probe_devicefunction iommu_probe_devicefunction __iommu_group_free_devicefunction __iommu_group_remove_devicefunction iommu_release_devicefunction iommu_set_def_domain_typefunction iommu_dma_setupfunction iommu_set_dma_strictfunction iommu_group_attr_showfunction iommu_group_attr_storefunction iommu_group_create_filefunction iommu_group_remove_filefunction iommu_group_show_namefunction iommu_insert_resv_regionfunction iommu_insert_device_resv_regionsfunction list_for_each_entryfunction iommu_get_group_resv_regionsfunction iommu_group_show_resv_regionsfunction list_for_each_entry_safefunction iommu_group_show_typefunction iommu_group_releasefunction iommu_group_putfunction iommu_group_set_iommudatafunction iommu_group_set_namefunction iommu_create_device_direct_mappingsfunction iommu_group_add_device
Annotated Snippet
static int bus_iommu_probe(const struct bus_type *bus);
static int iommu_bus_notifier(struct notifier_block *nb,
unsigned long action, void *data);
static void iommu_release_device(struct device *dev);
static int __iommu_attach_device(struct iommu_domain *domain,
struct device *dev, struct iommu_domain *old);
static int __iommu_attach_group(struct iommu_domain *domain,
struct iommu_group *group);
static struct iommu_domain *__iommu_paging_domain_alloc_flags(struct device *dev,
unsigned int type,
unsigned int flags);
enum {
IOMMU_SET_DOMAIN_MUST_SUCCEED = 1 << 0,
};
static int __iommu_device_set_domain(struct iommu_group *group,
struct device *dev,
struct iommu_domain *new_domain,
struct iommu_domain *old_domain,
unsigned int flags);
static int __iommu_group_set_domain_internal(struct iommu_group *group,
struct iommu_domain *new_domain,
unsigned int flags);
static int __iommu_group_set_domain(struct iommu_group *group,
struct iommu_domain *new_domain)
{
return __iommu_group_set_domain_internal(group, new_domain, 0);
}
static void __iommu_group_set_domain_nofail(struct iommu_group *group,
struct iommu_domain *new_domain)
{
WARN_ON(__iommu_group_set_domain_internal(
group, new_domain, IOMMU_SET_DOMAIN_MUST_SUCCEED));
}
static int iommu_setup_default_domain(struct iommu_group *group,
int target_type);
static int iommu_create_device_direct_mappings(struct iommu_domain *domain,
struct device *dev);
static ssize_t iommu_group_store_type(struct iommu_group *group,
const char *buf, size_t count);
static struct group_device *iommu_group_alloc_device(struct iommu_group *group,
struct device *dev);
static void __iommu_group_free_device(struct iommu_group *group,
struct group_device *grp_dev);
static void iommu_domain_init(struct iommu_domain *domain, unsigned int type,
const struct iommu_ops *ops);
#define IOMMU_GROUP_ATTR(_name, _mode, _show, _store) \
struct iommu_group_attribute iommu_group_attr_##_name = \
__ATTR(_name, _mode, _show, _store)
#define to_iommu_group_attr(_attr) \
container_of(_attr, struct iommu_group_attribute, attr)
#define to_iommu_group(_kobj) \
container_of(_kobj, struct iommu_group, kobj)
static LIST_HEAD(iommu_device_list);
static DEFINE_SPINLOCK(iommu_device_lock);
static const struct bus_type * const iommu_buses[] = {
&platform_bus_type,
#ifdef CONFIG_PCI
&pci_bus_type,
#endif
#ifdef CONFIG_ARM_AMBA
&amba_bustype,
#endif
#ifdef CONFIG_FSL_MC_BUS
&fsl_mc_bus_type,
#endif
#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS
&host1x_context_device_bus_type,
#endif
#ifdef CONFIG_CDX_BUS
&cdx_bus_type,
#endif
};
/*
* Use a function instead of an array here because the domain-type is a
* bit-field, so an array would waste memory.
*/
static const char *iommu_domain_type_str(unsigned int t)
{
switch (t) {
case IOMMU_DOMAIN_BLOCKED:
return "Blocked";
case IOMMU_DOMAIN_IDENTITY:
Annotation
- Immediate include surface: `linux/amba/bus.h`, `linux/device.h`, `linux/kernel.h`, `linux/bits.h`, `linux/bug.h`, `linux/types.h`, `linux/init.h`, `linux/export.h`.
- Detected declarations: `struct iommu_group`, `struct group_device`, `struct iommu_group_attribute`, `struct group_for_pci_data`, `function for_each_group_device`, `function __iommu_group_set_domain`, `function __iommu_group_set_domain_nofail`, `function iommu_subsys_init`, `function remove_iommu_group`, `function iommu_device_register`.
- Atlas domain: Driver Families / drivers/iommu.
- 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.