Lines Matching +full:cpu +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0
4 * Hyper-V stub IOMMU driver.
18 #include <asm/cpu.h>
30 * According 82093AA IO-APIC spec , IO APIC has a 24-entry Interrupt
31 * Redirection Table. Hyper-V exposes one single IO-APIC and so define
42 struct irq_data *parent = data->parent_data; in hyperv_ir_set_affinity()
43 struct irq_cfg *cfg = irqd_cfg(data); in hyperv_ir_set_affinity() local
48 return -EINVAL; in hyperv_ir_set_affinity()
50 ret = parent->chip->irq_set_affinity(parent, mask, force); in hyperv_ir_set_affinity()
54 vector_schedule_cleanup(cfg); in hyperv_ir_set_affinity()
60 .name = "HYPERV-IR",
73 if (!info || info->type != X86_IRQ_ALLOC_TYPE_IOAPIC || nr_irqs > 1) in hyperv_irq_remapping_alloc()
74 return -EINVAL; in hyperv_irq_remapping_alloc()
83 return -EINVAL; in hyperv_irq_remapping_alloc()
86 irq_data->chip = &hyperv_ir_chip; in hyperv_irq_remapping_alloc()
89 * Hypver-V IO APIC irq affinity should be in the scope of in hyperv_irq_remapping_alloc()
107 /* Claim the only I/O APIC emulated by Hyper-V */ in hyperv_irq_remapping_select()
126 * For a Hyper-V root partition, ms_hyperv_msi_ext_dest_id() in hyperv_prepare_irq_remapping()
131 return -ENODEV; in hyperv_prepare_irq_remapping()
134 name = "HYPERV-ROOT-IR"; in hyperv_prepare_irq_remapping()
137 name = "HYPERV-IR"; in hyperv_prepare_irq_remapping()
143 return -ENOMEM; in hyperv_prepare_irq_remapping()
151 return -ENOMEM; in hyperv_prepare_irq_remapping()
158 * Hyper-V doesn't provide irq remapping function for in hyperv_prepare_irq_remapping()
159 * IO-APIC and so IO-APIC only accepts 8-bit APIC ID. in hyperv_prepare_irq_remapping()
160 * Cpu's APIC ID is read from ACPI MADT table and APIC IDs in hyperv_prepare_irq_remapping()
161 * in the MADT table on Hyper-v are sorted monotonic increasingly. in hyperv_prepare_irq_remapping()
162 * APIC ID reflects cpu topology. There maybe some APIC ID in hyperv_prepare_irq_remapping()
163 * gaps when cpu number in a socket is not power of two. Prepare in hyperv_prepare_irq_remapping()
164 * max cpu affinity for IOAPIC irqs. Scan cpu 0-255 and set cpu in hyperv_prepare_irq_remapping()
167 for (i = min_t(unsigned int, num_possible_cpus() - 1, 255); i >= 0; i--) in hyperv_prepare_irq_remapping()
198 struct irq_cfg *cfg; in hyperv_root_ir_compose_msi_msg() local
201 int cpu; in hyperv_root_ir_compose_msi_msg() local
203 struct hyperv_root_ir_data *data = irq_data->chip_data; in hyperv_root_ir_compose_msi_msg()
206 cfg = irqd_cfg(irq_data); in hyperv_root_ir_compose_msi_msg()
208 cpu = cpumask_first_and(affinity, cpu_online_mask); in hyperv_root_ir_compose_msi_msg()
210 vector = cfg->vector; in hyperv_root_ir_compose_msi_msg()
211 ioapic_id = data->ioapic_id; in hyperv_root_ir_compose_msi_msg()
213 if (data->entry.source == HV_DEVICE_TYPE_IOAPIC in hyperv_root_ir_compose_msi_msg()
214 && data->entry.ioapic_rte.as_uint64) { in hyperv_root_ir_compose_msi_msg()
215 entry = data->entry; in hyperv_root_ir_compose_msi_msg()
222 data->entry.ioapic_rte.as_uint64 = 0; in hyperv_root_ir_compose_msi_msg()
223 data->entry.source = 0; /* Invalid source */ in hyperv_root_ir_compose_msi_msg()
227 status = hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu, in hyperv_root_ir_compose_msi_msg()
235 data->entry = entry; in hyperv_root_ir_compose_msi_msg()
242 msg->arch_data.vector = e.vector; in hyperv_root_ir_compose_msi_msg()
243 msg->arch_data.delivery_mode = e.delivery_mode; in hyperv_root_ir_compose_msi_msg()
244 msg->arch_addr_lo.dest_mode_logical = e.dest_mode_logical; in hyperv_root_ir_compose_msi_msg()
245 msg->arch_addr_lo.dmar_format = e.ir_format; in hyperv_root_ir_compose_msi_msg()
246 msg->arch_addr_lo.dmar_index_0_14 = e.ir_index_0_14; in hyperv_root_ir_compose_msi_msg()
252 struct irq_data *parent = data->parent_data; in hyperv_root_ir_set_affinity()
253 struct irq_cfg *cfg = irqd_cfg(data); in hyperv_root_ir_set_affinity() local
256 ret = parent->chip->irq_set_affinity(parent, mask, force); in hyperv_root_ir_set_affinity()
260 vector_schedule_cleanup(cfg); in hyperv_root_ir_set_affinity()
266 .name = "HYPERV-ROOT-IR",
281 if (!info || info->type != X86_IRQ_ALLOC_TYPE_IOAPIC || nr_irqs > 1) in hyperv_root_irq_remapping_alloc()
282 return -EINVAL; in hyperv_root_irq_remapping_alloc()
291 return -ENOMEM; in hyperv_root_irq_remapping_alloc()
298 return -EINVAL; in hyperv_root_irq_remapping_alloc()
301 data->ioapic_id = info->devid; in hyperv_root_irq_remapping_alloc()
302 data->is_level = info->ioapic.is_level; in hyperv_root_irq_remapping_alloc()
304 irq_data->chip = &hyperv_root_ir_chip; in hyperv_root_irq_remapping_alloc()
305 irq_data->chip_data = data; in hyperv_root_irq_remapping_alloc()
321 if (irq_data && irq_data->chip_data) { in hyperv_root_irq_remapping_free()
322 data = irq_data->chip_data; in hyperv_root_irq_remapping_free()
323 e = &data->entry; in hyperv_root_irq_remapping_free()
325 if (e->source == HV_DEVICE_TYPE_IOAPIC in hyperv_root_irq_remapping_free()
326 && e->ioapic_rte.as_uint64) in hyperv_root_irq_remapping_free()
327 hv_unmap_ioapic_interrupt(data->ioapic_id, in hyperv_root_irq_remapping_free()
328 &data->entry); in hyperv_root_irq_remapping_free()