Skip to content

Commit 4ae13c2

Browse files
sean-jcjfvogel
authored andcommitted
iommu/vt-d: Put IRTE back into posted MSI mode if vCPU posting is disabled
commit 2454823e97a63d85a6b215905f71e5a06324eab7 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit c95a438d2c37748541b696053cd5c72042c838ad) Signed-off-by: Jack Vogel <[email protected]>
1 parent b05989a commit 4ae13c2

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
@@ -1173,7 +1173,17 @@ static void intel_ir_reconfigure_irte_posted(struct irq_data *irqd)
11731173
static inline void intel_ir_reconfigure_irte_posted(struct irq_data *irqd) {}
11741174
#endif
11751175

1176-
static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
1176+
static void __intel_ir_reconfigure_irte(struct irq_data *irqd, bool force_host)
1177+
{
1178+
struct intel_ir_data *ir_data = irqd->chip_data;
1179+
1180+
if (ir_data->irq_2_iommu.posted_msi)
1181+
intel_ir_reconfigure_irte_posted(irqd);
1182+
else if (force_host || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1183+
modify_irte(&ir_data->irq_2_iommu, &ir_data->irte_entry);
1184+
}
1185+
1186+
static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force_host)
11771187
{
11781188
struct intel_ir_data *ir_data = irqd->chip_data;
11791189
struct irte *irte = &ir_data->irte_entry;
@@ -1186,10 +1196,7 @@ static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
11861196
irte->vector = cfg->vector;
11871197
irte->dest_id = IRTE_DEST(cfg->dest_apicid);
11881198

1189-
if (ir_data->irq_2_iommu.posted_msi)
1190-
intel_ir_reconfigure_irte_posted(irqd);
1191-
else if (force || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1192-
modify_irte(&ir_data->irq_2_iommu, irte);
1199+
__intel_ir_reconfigure_irte(irqd, force_host);
11931200
}
11941201

11951202
/*
@@ -1244,7 +1251,7 @@ static int intel_ir_set_vcpu_affinity(struct irq_data *data, void *info)
12441251

12451252
/* stop posting interrupts, back to the default mode */
12461253
if (!vcpu_pi_info) {
1247-
modify_irte(&ir_data->irq_2_iommu, &ir_data->irte_entry);
1254+
__intel_ir_reconfigure_irte(data, true);
12481255
} else {
12491256
struct irte irte_pi;
12501257

0 commit comments

Comments
 (0)