Skip to contentSkip to conversation

Patch "genirq/msi: Make sure PCI MSIs are activated early" has been added to the 4.7-stable tree

PATCH [email protected] 1 participant 1 message Sep 2, 2016

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

genirq/msi: Make sure PCI MSIs are activated early

to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
genirq-msi-make-sure-pci-msis-are-activated-early.patch
and it can be found in the queue-4.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From f3b0946d629c8bfbd3e5f038e30cb9c711a35f10 Mon Sep 17 00:00:00 2001

From: Marc Zyngier <[email protected]>
Date: Wed, 13 Jul 2016 17:18:33 +0100
Subject: genirq/msi: Make sure PCI MSIs are activated early

From: Marc Zyngier <[email protected]>

commit f3b0946d629c8bfbd3e5f038e30cb9c711a35f10 upstream.

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?

---
 drivers/pci/msi.c   |    2 ++
 include/linux/msi.h |    2 ++
 kernel/irq/msi.c    |   11 +++++++++++
 3 files changed, 15 insertions(+)
drivers/pci/msi.c +2 -0
@@ -1277,6 +1277,8 @@ struct irq_domain *pci_msi_create_irq_do
 	if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS)
 		pci_msi_domain_update_chip_ops(info);
 
+	info->flags |= MSI_FLAG_ACTIVATE_EARLY;
+
 	domain = msi_create_irq_domain(fwnode, info, parent);
 	if (!domain)
 		return NULL;
include/linux/msi.h +2 -0
@@ -268,6 +268,8 @@ enum {
 	MSI_FLAG_MULTI_PCI_MSI		= (1 << 2),
 	/* Support PCI MSIX interrupts */
 	MSI_FLAG_PCI_MSIX		= (1 << 3),
+	/* Needs early activate, required for PCI */
+	MSI_FLAG_ACTIVATE_EARLY		= (1 << 4),
 };
 
 int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
kernel/irq/msi.c +11 -0
@@ -357,6 +357,17 @@ int msi_domain_alloc_irqs(struct irq_dom
 		else
 			dev_dbg(dev, "irq [%d-%d] for MSI\n",
 				virq, virq + desc->nvec_used - 1);
+		/*
+		 * This flag is set by the PCI layer as we need to activate
+		 * the MSI entries before the PCI layer enables MSI in the
+		 * card. Otherwise the card latches a random msi message.
+		 */
+		if (info->flags & MSI_FLAG_ACTIVATE_EARLY) {
+			struct irq_data *irq_data;
+
+			irq_data = irq_domain_get_irq_data(domain, desc->irq);
+			irq_domain_activate_irq(irq_data);
+		}
 	}
 
 	return 0;

Patches currently in stable-queue which might be from [email protected] are

queue-4.7/genirq-msi-make-sure-pci-msis-are-activated-early.patch