Skip to content

Commit 2454823

Browse files
sean-jcjoergroedel
authored andcommitted
iommu/vt-d: Put IRTE back into posted MSI mode if vCPU posting is disabled
Add a helper to take care of reconfiguring an IRTE to deliver IRQs to the host, i.e. not to a vCPU, and use the helper when an IRTE's vCPU affinity is nullified, i.e. when KVM puts an IRTE back into "host" mode. Because posted MSIs use an ephemeral IRTE, using modify_irte() puts the IRTE into full remapped mode, i.e. unintentionally disables posted MSIs on the IRQ. Fixes: ed1e48e ("iommu/vt-d: Enable posted mode for device MSIs") Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: Jacob Pan <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 4c293ad commit 2454823

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/iommu/intel/irq_remapping.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,17 @@ static void intel_ir_reconfigure_irte_posted(struct irq_data *irqd)
11691169
static inline void intel_ir_reconfigure_irte_posted(struct irq_data *irqd) {}
11701170
#endif
11711171

1172-
static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
1172+
static void __intel_ir_reconfigure_irte(struct irq_data *irqd, bool force_host)
1173+
{
1174+
struct intel_ir_data *ir_data = irqd->chip_data;
1175+
1176+
if (ir_data->irq_2_iommu.posted_msi)
1177+
intel_ir_reconfigure_irte_posted(irqd);
1178+
else if (force_host || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1179+
modify_irte(&ir_data->irq_2_iommu, &ir_data->irte_entry);
1180+
}
1181+
1182+
static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force_host)
11731183
{
11741184
struct intel_ir_data *ir_data = irqd->chip_data;
11751185
struct irte *irte = &ir_data->irte_entry;
@@ -1182,10 +1192,7 @@ static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
11821192
irte->vector = cfg->vector;
11831193
irte->dest_id = IRTE_DEST(cfg->dest_apicid);
11841194

1185-
if (ir_data->irq_2_iommu.posted_msi)
1186-
intel_ir_reconfigure_irte_posted(irqd);
1187-
else if (force || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1188-
modify_irte(&ir_data->irq_2_iommu, irte);
1195+
__intel_ir_reconfigure_irte(irqd, force_host);
11891196
}
11901197

11911198
/*
@@ -1240,7 +1247,7 @@ static int intel_ir_set_vcpu_affinity(struct irq_data *data, void *info)
12401247

12411248
/* stop posting interrupts, back to the default mode */
12421249
if (!vcpu_pi_info) {
1243-
modify_irte(&ir_data->irq_2_iommu, &ir_data->irte_entry);
1250+
__intel_ir_reconfigure_irte(data, true);
12441251
} else {
12451252
struct irte irte_pi;
12461253

0 commit comments

Comments
 (0)