drivers/iommu/hyperv/hv-irq-remap-x86.c
Source file repositories/reference/linux-study-clean/drivers/iommu/hyperv/hv-irq-remap-x86.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/hyperv/hv-irq-remap-x86.c- Extension
.c- Size
- 8480 bytes
- Lines
- 331
- Domain
- Driver Families
- Bucket
- drivers/iommu
- 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.
- 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/types.hlinux/interrupt.hlinux/irq.hlinux/iommu.hlinux/module.hasm/apic.hasm/cpu.hasm/hw_irq.hasm/io_apic.hasm/irq_remapping.hasm/hypervisor.hasm/mshyperv.h../irq_remapping.h
Detected Declarations
struct hyperv_root_ir_datafunction hyperv_ir_set_affinityfunction hyperv_irq_remapping_allocfunction hyperv_irq_remapping_freefunction hyperv_irq_remapping_selectfunction hyperv_prepare_irq_remappingfunction hyperv_enable_irq_remappingfunction hyperv_root_ir_compose_msi_msgfunction hyperv_root_ir_set_affinityfunction hyperv_root_irq_remapping_allocfunction hyperv_root_irq_remapping_free
Annotated Snippet
struct hyperv_root_ir_data {
u8 ioapic_id;
bool is_level;
struct hv_interrupt_entry entry;
};
static void
hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *msg)
{
struct hyperv_root_ir_data *data = irq_data->chip_data;
struct hv_interrupt_entry entry;
const struct cpumask *affinity;
struct IO_APIC_route_entry e;
struct irq_cfg *cfg;
int cpu, ioapic_id;
u32 vector;
cfg = irqd_cfg(irq_data);
affinity = irq_data_get_effective_affinity_mask(irq_data);
cpu = cpumask_first_and(affinity, cpu_online_mask);
vector = cfg->vector;
ioapic_id = data->ioapic_id;
if (data->entry.source == HV_DEVICE_TYPE_IOAPIC
&& data->entry.ioapic_rte.as_uint64) {
entry = data->entry;
(void)hv_unmap_ioapic_interrupt(ioapic_id, &entry);
data->entry.ioapic_rte.as_uint64 = 0;
data->entry.source = 0; /* Invalid source */
}
if (hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu,
vector, &entry))
return;
data->entry = entry;
/* Turn it into an IO_APIC_route_entry, and generate MSI MSG. */
e.w1 = entry.ioapic_rte.low_uint32;
e.w2 = entry.ioapic_rte.high_uint32;
memset(msg, 0, sizeof(*msg));
msg->arch_data.vector = e.vector;
msg->arch_data.delivery_mode = e.delivery_mode;
msg->arch_addr_lo.dest_mode_logical = e.dest_mode_logical;
msg->arch_addr_lo.dmar_format = e.ir_format;
msg->arch_addr_lo.dmar_index_0_14 = e.ir_index_0_14;
}
static int hyperv_root_ir_set_affinity(struct irq_data *data,
const struct cpumask *mask, bool force)
{
struct irq_data *parent = data->parent_data;
struct irq_cfg *cfg = irqd_cfg(data);
int ret;
ret = parent->chip->irq_set_affinity(parent, mask, force);
if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE)
return ret;
vector_schedule_cleanup(cfg);
return 0;
}
static struct irq_chip hyperv_root_ir_chip = {
.name = "HYPERV-ROOT-IR",
.irq_ack = apic_ack_irq,
.irq_set_affinity = hyperv_root_ir_set_affinity,
.irq_compose_msi_msg = hyperv_root_ir_compose_msi_msg,
};
static int hyperv_root_irq_remapping_alloc(struct irq_domain *domain,
unsigned int virq, unsigned int nr_irqs,
void *arg)
{
struct irq_alloc_info *info = arg;
struct irq_data *irq_data;
struct hyperv_root_ir_data *data;
int ret = 0;
if (!info || info->type != X86_IRQ_ALLOC_TYPE_IOAPIC || nr_irqs > 1)
return -EINVAL;
ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg);
if (ret < 0)
Annotation
- Immediate include surface: `linux/types.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/iommu.h`, `linux/module.h`, `asm/apic.h`, `asm/cpu.h`, `asm/hw_irq.h`.
- Detected declarations: `struct hyperv_root_ir_data`, `function hyperv_ir_set_affinity`, `function hyperv_irq_remapping_alloc`, `function hyperv_irq_remapping_free`, `function hyperv_irq_remapping_select`, `function hyperv_prepare_irq_remapping`, `function hyperv_enable_irq_remapping`, `function hyperv_root_ir_compose_msi_msg`, `function hyperv_root_ir_set_affinity`, `function hyperv_root_irq_remapping_alloc`.
- Atlas domain: Driver Families / drivers/iommu.
- Implementation status: source implementation candidate.
- 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.