drivers/iommu/amd/init.c
Source file repositories/reference/linux-study-clean/drivers/iommu/amd/init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/amd/init.c- Extension
.c- Size
- 101797 bytes
- Lines
- 4107
- Domain
- Driver Families
- Bucket
- drivers/iommu
- 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/list.hlinux/bitmap.hlinux/syscore_ops.hlinux/interrupt.hlinux/msi.hlinux/irq.hlinux/amd-iommu.hlinux/export.hlinux/kmemleak.hlinux/cc_platform.hlinux/iopoll.hasm/pci-direct.hasm/iommu.hasm/apic.hasm/gart.hasm/x86_init.hasm/io_apic.hasm/irq_remapping.hasm/set_memory.hasm/sev.hlinux/crash_dump.hamd_iommu.h../irq_remapping.h../iommu-pages.h
Detected Declarations
struct ivhd_headerstruct ivhd_entrystruct ivmd_headerenum iommu_init_statefunction translation_pre_enabledfunction clear_translation_pre_enabledfunction init_translation_statusfunction amd_iommu_get_num_iommusfunction amd_iommu_ht_range_ignorefunction get_global_efrfunction for_each_iommufunction early_iommu_features_initfunction iommu_read_l1function iommu_write_l1function iommu_read_l2function iommu_write_l2function iommu_set_cwwb_rangefunction iommu_set_device_tablefunction iommu_feature_setfunction iommu_feature_enablefunction iommu_feature_disablefunction iommu_enablefunction iommu_disablefunction iommu_map_mmio_spacefunction iommu_unmap_mmio_spacefunction get_ivhd_header_sizefunction ivhd_entry_lengthfunction find_last_devid_from_ivhdfunction check_ivrs_checksumfunction find_last_devid_acpifunction alloc_dev_tablefunction free_dev_tablefunction alloc_rlookup_tablefunction free_rlookup_tablefunction alloc_irq_lookup_tablefunction free_irq_lookup_tablefunction alloc_alias_tablefunction free_alias_tablefunction alloc_command_bufferfunction amd_iommu_restart_logfunction amd_iommu_restart_event_loggingfunction amd_iommu_restart_ga_logfunction amd_iommu_reset_cmd_bufferfunction iommu_enable_command_bufferfunction iommu_disable_command_bufferfunction free_command_bufferfunction iommu_alloc_4k_pagesfunction set_memory_4k
Annotated Snippet
struct ivhd_header {
u8 type;
u8 flags;
u16 length;
u16 devid;
u16 cap_ptr;
u64 mmio_phys;
u16 pci_seg;
u16 info;
u32 efr_attr;
/* Following only valid on IVHD type 11h and 40h */
u64 efr_reg; /* Exact copy of MMIO_EXT_FEATURES */
u64 efr_reg2;
} __attribute__((packed));
/*
* A device entry describing which devices a specific IOMMU translates and
* which requestor ids they use.
*/
struct ivhd_entry {
u8 type;
u16 devid;
u8 flags;
struct_group(ext_hid,
u32 ext;
u32 hidh;
);
u64 cid;
u8 uidf;
u8 uidl;
u8 uid;
} __attribute__((packed));
int amd_iommu_evtlog_size = EVTLOG_SIZE_DEF;
int amd_iommu_pprlog_size = PPRLOG_SIZE_DEF;
/*
* An AMD IOMMU memory definition structure. It defines things like exclusion
* ranges for devices and regions that should be unity mapped.
*/
struct ivmd_header {
u8 type;
u8 flags;
u16 length;
u16 devid;
u16 aux;
u16 pci_seg;
u8 resv[6];
u64 range_start;
u64 range_length;
} __attribute__((packed));
bool amd_iommu_dump;
bool amd_iommu_irq_remap __read_mostly;
enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1;
/* Virtual address size */
u8 amd_iommu_hpt_vasize;
/* Guest page table level */
int amd_iommu_gpt_level = PAGE_MODE_4_LEVEL;
int amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_VAPIC;
static int amd_iommu_xt_mode = IRQ_REMAP_XAPIC_MODE;
static bool amd_iommu_detected;
static bool amd_iommu_disabled __initdata;
static bool amd_iommu_force_enable __initdata;
static bool amd_iommu_irtcachedis;
static int amd_iommu_target_ivhd_type;
/* Global EFR and EFR2 registers */
u64 amd_iommu_efr;
u64 amd_iommu_efr2;
/* Host (v1) page table is not supported*/
bool amd_iommu_hatdis;
/* SNP is enabled on the system? */
bool amd_iommu_snp_en;
EXPORT_SYMBOL(amd_iommu_snp_en);
LIST_HEAD(amd_iommu_pci_seg_list); /* list of all PCI segments */
LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the system */
LIST_HEAD(amd_ivhd_dev_flags_list); /* list of all IVHD device entry settings */
/* Number of IOMMUs present in the system */
static int amd_iommus_present;
/* IOMMUs have a non-present cache? */
Annotation
- Immediate include surface: `linux/pci.h`, `linux/acpi.h`, `linux/list.h`, `linux/bitmap.h`, `linux/syscore_ops.h`, `linux/interrupt.h`, `linux/msi.h`, `linux/irq.h`.
- Detected declarations: `struct ivhd_header`, `struct ivhd_entry`, `struct ivmd_header`, `enum iommu_init_state`, `function translation_pre_enabled`, `function clear_translation_pre_enabled`, `function init_translation_status`, `function amd_iommu_get_num_iommus`, `function amd_iommu_ht_range_ignore`, `function get_global_efr`.
- Atlas domain: Driver Families / drivers/iommu.
- 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.