aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2016-07-13 12:18:33 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-08-09 03:19:32 -0400
commitf3b0946d629c8bfbd3e5f038e30cb9c711a35f10 (patch)
treedb1a60c625dab7f046cef8f4975f5fbed151a3dc
parent81abf2525827b29839a78fd55ab0699f033c41a5 (diff)
genirq/msi: Make sure PCI MSIs are activated early
Bharat Kumar Gogada reported issues with the generic MSI code, where the end-point ended up with garbage in its MSI configuration (both for the vector and the message). It turns out that the two MSI paths in the kernel are doing slightly different things: generic MSI: disable MSI -> allocate MSI -> enable MSI -> setup EP PCI MSI: disable MSI -> allocate MSI -> setup EP -> enable MSI And it turns out that end-points are allowed to latch the content of the MSI configuration registers as soon as MSIs are enabled. In Bharat's case, the end-point ends up using whatever was there already, which is not what you want. In order to make things converge, we introduce a new MSI domain flag (MSI_FLAG_ACTIVATE_EARLY) that is unconditionally set for PCI/MSI. When set, this flag forces the programming of the end-point as soon as the MSIs are allocated. A consequence of this is that we have an extra activate in irq_startup, but that should be without much consequence. tglx: - Several people reported a VMWare regression with PCI/MSI-X passthrough. It turns out that the patch also cures that issue. - We need to have a look at the MSI disable interrupt path, where we write the msg to all zeros without disabling MSI in the PCI device. Is that correct? Fixes: 52f518a3a7c2 "x86/MSI: Use hierarchical irqdomains to manage MSI interrupts" Reported-and-tested-by: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com> Reported-and-tested-by: Foster Snowhill <forst@forstwoof.ru> Reported-by: Matthias Prager <linux@matthiasprager.de> Reported-by: Jason Taylor <jason.taylor@simplivity.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Cc: linux-pci@vger.kernel.org Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1468426713-31431-1-git-send-email-marc.zyngier@arm.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--drivers/pci/msi.c2
-rw-r--r--include/linux/msi.h2
-rw-r--r--kernel/irq/msi.c11
3 files changed, 15 insertions, 0 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index a02981efdad5..eafa6138a6b8 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1411,6 +1411,8 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
1411 if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) 1411 if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS)
1412 pci_msi_domain_update_chip_ops(info); 1412 pci_msi_domain_update_chip_ops(info);
1413 1413
1414 info->flags |= MSI_FLAG_ACTIVATE_EARLY;
1415
1414 domain = msi_create_irq_domain(fwnode, info, parent); 1416 domain = msi_create_irq_domain(fwnode, info, parent);
1415 if (!domain) 1417 if (!domain)
1416 return NULL; 1418 return NULL;
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 4f0bfe5912b2..e8c81fbd5f9c 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -270,6 +270,8 @@ enum {
270 MSI_FLAG_MULTI_PCI_MSI = (1 << 2), 270 MSI_FLAG_MULTI_PCI_MSI = (1 << 2),
271 /* Support PCI MSIX interrupts */ 271 /* Support PCI MSIX interrupts */
272 MSI_FLAG_PCI_MSIX = (1 << 3), 272 MSI_FLAG_PCI_MSIX = (1 << 3),
273 /* Needs early activate, required for PCI */
274 MSI_FLAG_ACTIVATE_EARLY = (1 << 4),
273}; 275};
274 276
275int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, 277int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 54999350162c..19e9dfbe97fa 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -359,6 +359,17 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
359 else 359 else
360 dev_dbg(dev, "irq [%d-%d] for MSI\n", 360 dev_dbg(dev, "irq [%d-%d] for MSI\n",
361 virq, virq + desc->nvec_used - 1); 361 virq, virq + desc->nvec_used - 1);
362 /*
363 * This flag is set by the PCI layer as we need to activate
364 * the MSI entries before the PCI layer enables MSI in the
365 * card. Otherwise the card latches a random msi message.
366 */
367 if (info->flags & MSI_FLAG_ACTIVATE_EARLY) {
368 struct irq_data *irq_data;
369
370 irq_data = irq_domain_get_irq_data(domain, desc->irq);
371 irq_domain_activate_irq(irq_data);
372 }
362 } 373 }
363 374
364 return 0; 375 return 0;